source: mauRepo/MolesManager/trunk/src/libs/migration/tests/commontest.py @ 8445

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/tests/commontest.py@8475
Revision 8445, 2.0 KB checked in by mnagni, 7 years ago (diff)

Complete - # 22489: CEDA Observation Collection - phenomenonTime
 http://team.ceda.ac.uk/trac/ceda/ticket/22489
Complete - # 22488: CEDA Observation Collection - Geographical Extent
 http://team.ceda.ac.uk/trac/ceda/ticket/22488

Line 
1'''
2Created on 7 Mar 2012
3
4@author: mnagni
5'''
6from unittest import TestCase
7from libs.migration.processor.commons import isoDateTimeStringToTimeDate,\
8    fromDateStringToPhenomenonTime, fromPhenomenonTimeToString,\
9    comparePhenomenonTimes
10
11
12class CommonTest(TestCase):
13    '''
14    classdocs
15    '''
16
17    def testIsoDateTimeStringToTimeDate_1(self):
18        time1 = '2009-12-10T03:16:25Z'
19        isoDateTimeStringToTimeDate(time1)
20
21    def testIsoDateTimeStringToTimeDate_2(self):
22        time1 = '2009 12 10T03:16:25Z'
23        self.assertRaises(ValueError, isoDateTimeStringToTimeDate, time1)
24
25    def testFromDateStringToPhenomenonTime(self):
26        temporalRange = '2002-07-22/2011-08-06'
27        pt = fromDateStringToPhenomenonTime(temporalRange)
28        print pt
29       
30    def testFromPhenomenonTimeToString(self):
31        temporalRange = '2002-07-22/2011-08-06'
32        pt = fromDateStringToPhenomenonTime(temporalRange)
33        ptString = fromPhenomenonTimeToString(pt)
34        startDate, endDate = temporalRange.split('/')       
35        self.assertTrue(startDate == ptString[0], "Error")       
36        self.assertTrue(endDate == ptString[1], "Error")       
37       
38        temporalRange = '2002-07-22'
39        pt = fromDateStringToPhenomenonTime(temporalRange)
40        ptString = fromPhenomenonTimeToString(pt)
41        startDate, endDate = temporalRange, None       
42        self.assertTrue(startDate == ptString[0], "Error")       
43        self.assertTrue(endDate == ptString[1], "Error")
44       
45    def testComparePhenomenonTimes(self):
46        p1 = fromDateStringToPhenomenonTime('2002-07-22/2011-08-06')
47        p2 = fromDateStringToPhenomenonTime('2002-07-22/2011-08-06')
48        self.assertTrue(comparePhenomenonTimes(p1,p2), "Error")
49       
50        p2 = fromDateStringToPhenomenonTime('2002-07-22/2011-08-05')
51        self.assertFalse(comparePhenomenonTimes(p1,p2), "Error")
52       
53        p2 = fromDateStringToPhenomenonTime('2002-07-22')
54        self.assertFalse(comparePhenomenonTimes(p1,p2), "Error")
55       
Note: See TracBrowser for help on using the repository browser.