source: MILK/trunk/milk_server/milk_server/tests/models/testdif.py @ 4472

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/MILK/trunk/milk_server/milk_server/tests/models/testdif.py@4472
Revision 4472, 1.7 KB checked in by cbyrom, 12 years ago (diff)

Strip out code not relevant to MILK - mainly WCS and WMS stuff - also including the CSML server code + trackback code
Also tidy up structure of 'public' dir - setting up new 'style' dir and
centralising icons in icons dir + remove all unused icons, javascript and stylesheets.
Also strip out testcase code and populate new test directory structure.

Line 
1import unittest
2from milk_server.models.DIF import DIF
3
4class TestCase(unittest.TestCase):
5    """
6    Exercise the DIF model
7    """
8
9    # TODO: these files are not available in the codebase... fix!
10    inputFile = 'examples/neodc.eg1.dif'
11    inputFile2= 'examples/bodc.eg2.edmed.dif'
12    inputFile2= 'examples/bodc.eg3.difChange.dif'
13    inputFile2= 'examples/ndg.noc.soton.ac.uk__DIF__NOCSDAT162.xml'
14    configFile= 'config/ndgDiscovery.config'
15   
16    def setUp(self):
17        ''' Load example config and DIF files for testing '''
18        from ndgUtils.xmlHandler2 import xmlHandler
19        x=xmlHandler(self.inputFile2)
20        self.dif=DIF(x.tree,et=1)
21        self.config=myConfig(self.configFile)
22
23    def testEntries(self):
24        ''' Testing the DIF object can be loaded and some key entries extracted '''
25        print 'Entry ID [%s]'%self.dif.entryID
26        print 'Author [%s]'%self.dif.authors
27        print 'Abstract [%s]'%self.dif.abstract
28        print 'BBox [%s]'%self.dif.bbox.boxes
29   
30    def testParameters(self):
31        ''' Testing obtaining parameters from an edmed dif in original format '''
32        print 'Parameters %s'%self.dif.parameters
33       
34    def testDifficult(self):
35        ''' Grab a test example from the internet and load it '''
36        from ndgUtils import ndgRetrieve, xmlHandler2
37        #testURI='grid.bodc.nerc.ac.uk__DIF__EDMED1048008'
38        testURI='neodc.nerc.ac.uk__DIF__NEODC_NEXTMAP'
39        uri=ndgObject(testURI,config=self.config)
40        status,xml=ndgRetrieve(uri,self.config)
41        self.assertEqual(status,1)
42        xml=xmlHandler2.xmlHandler(xml,string=1)
43        d=DIF(xml.tree,et=1)
44        print d.entryID,[str(i) for i in d.services]
45
46
47if __name__=="__main__":
48    unittest.main()
49
50       
Note: See TracBrowser for help on using the repository browser.