587
|
1 |
#============================================================================
|
|
2 |
#Name : test_ido.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
588
|
19 |
""" test IDO"""
|
587
|
20 |
|
|
21 |
import unittest
|
|
22 |
import ido
|
|
23 |
import logging
|
|
24 |
from datetime import datetime
|
|
25 |
from tempfile import mkstemp
|
|
26 |
import os
|
|
27 |
|
|
28 |
_logger = logging.getLogger('test.ido')
|
|
29 |
logging.basicConfig(level=logging.INFO)
|
|
30 |
|
|
31 |
class IDOTest(unittest.TestCase):
|
|
32 |
""" Verifying ido.py """
|
|
33 |
|
|
34 |
def test_ido(self):
|
|
35 |
""" Verifying is_in_interval method """
|
|
36 |
now = datetime.now()
|
|
37 |
status = ido.is_in_interval(1, '00:00', 4, '12:00')
|
|
38 |
|
|
39 |
# commenting it temproarily, will have to add a correct assertion here
|
|
40 |
# # in the odd week it should be True
|
|
41 |
# if int(now.strftime("%W")).__mod__(2):
|
|
42 |
# assert status == True
|
|
43 |
# # in the even week it should be False
|
|
44 |
# else :
|
|
45 |
# assert status == False
|
|
46 |
|
|
47 |
def test_ido_sysdef_valid(self):
|
|
48 |
""" Verifying get_sysdef_location method with valid sysdef"""
|
|
49 |
test_sysdef_file = os.path.join(os.environ['TEST_DATA'], 'data', 'packageiad', 'layers.sysdef.xml')
|
628
|
50 |
location = ido.get_sysdef_location(test_sysdef_file)
|
587
|
51 |
assert location != None
|
|
52 |
|
|
53 |
def test_ido_sysdef_invalid(self):
|
|
54 |
""" Verifying get_sysdef_location method with invalid sysdef"""
|
588
|
55 |
(f_d, filename) = mkstemp()
|
|
56 |
os.write(f_d,'Test sysdef file')
|
|
57 |
os.close(f_d)
|
628
|
58 |
location = ido.get_sysdef_location(filename)
|
587
|
59 |
os.unlink(filename)
|
|
60 |
assert location == None
|