source: exist/trunk/python/ndgUtils/testVocabTermData.py @ 4203

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/ndgUtils/testVocabTermData.py@4203
Revision 4203, 2.2 KB checked in by cbyrom, 11 years ago (diff)

Initialise eXist connection outside of atomiser classes - to allow
this to be done only once during data migration + move VocabTermData?
to ndgUtils so that it can be easily referenced from other apps.

Line 
1'''
2A test class for the Utilities module.
3
4C Byrom Jun 2008
5Tessella
6'''
7import unittest
8from ndgUtils.vocabtermdata import VocabTermData as VTD
9
10GCMD_URI = 'http://vocab.ndg.nerc.ac.uk/term/P201/1'
11UNVERSIONED_GCMD_URI1 = 'http://vocab.ndg.nerc.ac.uk/term/P201/'
12UNVERSIONED_GCMD_URI2 = 'http://vocab.ndg.nerc.ac.uk/term/P201'
13
14class testVocabTermData(unittest.TestCase):
15   
16    def setUp(self):
17        '''
18        set up data used in the tests.
19        '''
20        self.vtd = VTD()
21
22    def testValidGetTermVocabURL(self):
23        vocab = self.vtd.getTermCurrentVocabURL(VTD.CSML_TERM)
24        self.assertEquals(vocab, 'http://vocab.ndg.nerc.ac.uk/term/N021/2/1')
25       
26    def testGetLatestTermVersions(self):
27        self.vtd.getLatestTermVersions()
28        self.assertNotEquals(len(self.vtd.latestTermVersion), 0)
29       
30    def testGetLatestTermVersion(self):
31        self.vtd.getLatestTermVersion(VTD.LAS_TERM)
32        if VTD.LAS_TERM not in self.vtd.latestTermVersion:
33            self.fail("Did not look up latest term version")
34       
35    #def testInvalidGetLatestTermVersion(self):
36    #    self.assertRaises(ValueError,self.vtd.getLatestTermVersion, "blah")
37
38    def testGetTermCurrentVocabURL(self):
39        uri = self.vtd.getTermCurrentVocabURL(VTD.LAS_TERM)
40        self.assertEquals(uri, GCMD_URI + '/GCMDU006')
41
42    def testInvalidGetTermCurrentVocabURL(self):
43        self.assertRaises(ValueError, self.vtd.getTermCurrentVocabURL, "blah")
44       
45    def testGetVocabServerData(self):
46        self.vtd.getVocabServerData()
47        self.assertNotEquals(self.vtd.VOCAB_DATA_PAGE, None)
48        self.assertNotEquals(self.vtd.REFRESH_TIME, None)
49       
50    def testGetCurrentVocabURI(self):
51        uri = self.vtd.getCurrentVocabURI(GCMD_URI)
52        self.assertEquals(uri, GCMD_URI)
53       
54    def testGetCurrentVocabURIUnversioned1(self):
55        uri = self.vtd.getCurrentVocabURI(UNVERSIONED_GCMD_URI1)
56        self.assertEquals(uri, GCMD_URI)
57       
58    def testGetCurrentVocabURIUnversioned2(self):
59        uri = self.vtd.getCurrentVocabURI(UNVERSIONED_GCMD_URI2)
60        self.assertEquals(uri, GCMD_URI)
61
62if __name__ == '__main__':
63
64    unittest.main()
Note: See TracBrowser for help on using the repository browser.