source: exist/trunk/python/ndgUtils/test_ndgDirectory.py @ 4229

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

Add support for doing lists and summaries of atom docs via ndgDirectory and the existInterface class + add necessary xquery files for this + add new method to
allow retrieval of the collection to which an atom with a specified ID belongs - including the associated xquery file + extend tests to exercise these new features
+ add custom Atom error + improve preservation of key atom attributes when loading existing atoms into an Atom object + improve determining default atom collection

Line 
1from ndgDirectory import ndgDirectory
2
3import unittest
4
5class TestCase(unittest.TestCase):
6   
7    GLUE_DB = 'glue.badc.rl.ac.uk'
8    CHINOOK_DB = 'chinook.badc.rl.ac.uk'
9    def setUp(self): 
10        tc='/db/discovery/original/DIF/badc.nerc.ac.uk'
11        self.ndgDir=ndgDirectory(tc, self.GLUE_DB, docType='DIF')
12   
13    def testDirectory(self):
14        ''' Test the ability to get members of a directory and the first one of them '''
15        print self.ndgDir.members
16        doc=self.ndgDir.get(self.ndgDir.members[0]['fileName'])
17        print doc
18       
19    def testCreationDates(self):
20        '''Test the creation information'''
21        print self.ndgDir.created()
22        print self.ndgDir.created(self.ndgDir.members[0]['fileName'])
23       
24    def testAtomDocsDirectory(self):
25        self.ndgDir=ndgDirectory('/db/atoms', self.CHINOOK_DB,docType='ATOM')
26        self.assertTrue(len(self.ndgDir.members) > 0)
27        self.assertTrue(len(self.ndgDir.files) > 0)
28        self.assertTrue(len(self.ndgDir.entries) > 0)
29        self.assertNotEqual(self.ndgDir.get(self.ndgDir.members[0]['fileName']), None)
30       
31    def testAtomCreationDates(self):
32        self.ndgDir=ndgDirectory('/db/atoms', self.CHINOOK_DB,docType='ATOM')
33        self.assertNotEqual(self.ndgDir.created(), None)
34        self.assertNotEqual(self.ndgDir.created(fileName=self.ndgDir.members[0]['fileName']), None)
35       
36
37if __name__=="__main__":
38    unittest.main()
Note: See TracBrowser for help on using the repository browser.