source: ndgCommon/trunk/ndg/common/unittests/models/testmolesentity.py @ 5177

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/unittests/models/testmolesentity.py@5177
Revision 5177, 2.2 KB checked in by cbyrom, 12 years ago (diff)

Extend moles data model and schema to include the various new
metadata requested - updating the import/export methods + simplifying
object set up by allowing the use of the input dict to specify fields
+ extend test data and test suite.

Line 
1'''
2A test class for the GranuleAtom module.
3
4C Byrom Jun 2008
5Tessella
6'''
7import unittest
8import ndg.common.src.models.MolesEntity as ME
9from ndg.common.src.models.Atom import Atom
10from ndg.common.src.models.vocabtermdata import VocabTermData as VTD
11import ndg.common.unittests.testconstants as tc
12
13class testMolesEntity(unittest.TestCase):
14   
15    def setUp(self):
16        '''
17        set up data used in the tests.
18        '''
19        termURI = VTD().getTermCurrentVocabURL(VTD.GRANULE_TERM)
20        self.ME = ME.MolesEntity()
21        self.inputs = {'abbreviation':tc.ABBREVIATION,
22                       'providerID':tc.VALID_PROVIDER_ID,
23                       'createdDate':tc.createdDate,
24                       'datasetLanguage':tc.DATASET_LANGUAGE,
25                       'updateFrequency':tc.UPDATE_FREQUENCY,
26                       'verticalExtent':tc.VERTICAL_EXTENT,
27                       'spatialResolution':tc.SPATIAL_RESOLUTION}
28        for key, val in self.inputs.items():
29            setattr(self.ME, key, val)
30       
31       
32    def testInit(self):
33        self.checkVals()
34       
35    def testFromString(self):
36        self.ME.fromString(tc.MOLES_ENTITY_STRING)
37        self.checkVals()
38       
39    def testFromAtomString(self):
40        atom = Atom(xmlString = tc.xmlString)
41        self.ME = atom.ME
42        self.checkVals()
43       
44    def testFromInputs(self):
45        self.ME = ME.MolesEntity(**self.inputs)
46        self.checkVals()
47       
48       
49    def testFromAtomInputs(self):
50        self.ME = Atom(**self.inputs).ME
51        self.checkVals()
52
53    def checkVals(self):
54        self.assertEqual(tc.ABBREVIATION, self.ME.abbreviation)
55        self.assertEqual(tc.VALID_PROVIDER_ID, self.ME.providerID)
56        self.assertEqual(tc.createdDate, self.ME.createdDate)
57        self.assertEqual(tc.DATASET_LANGUAGE, self.ME.datasetLanguage)
58        self.assertEqual(tc.UPDATE_FREQUENCY, self.ME.updateFrequency)
59        self.assertEqual(tc.SPATIAL_RESOLUTION, self.ME.spatialResolution)
60        self.assertEqual(tc.VERTICAL_EXTENT, self.ME.verticalExtent)
61
62
63if __name__ == '__main__':
64
65    unittest.main()
Note: See TracBrowser for help on using the repository browser.