source: exist/trunk/python/ndgUtils/test_ndgRetrieve.py @ 3127

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/ndgUtils/test_ndgRetrieve.py@3127
Revision 3127, 2.1 KB checked in by lawrence, 12 years ago (diff)

This verison of ndgUtils does build to an egg. Next we need to
get dif2moles round trip testing working ... and solve
the related URL problem, and then we can work on the changes
to ndgObject which arise ... before trying to replace
the ows_server code.

Line 
1import ndgObject
2from ndgRetrieve import ndgRetrieve
3import ConfigParser
4import unittest
5
6class TestCase(unittest.TestCase):
7   
8    def setUp(self):
9       
10        f='test.config'
11        self.c=ConfigParser.ConfigParser()
12        self.c.read(f)
13           
14    def testEXIST(self):
15        ''' test link to local exist via xml rpc.
16                users will need to ensure that the document is actually
17                in your exist database! '''
18        doc='badc.nerc.ac.uk__NDG-B0__activity_activity_cwvc'
19        doc='neodc.nerc.ac.uk__NDG-B1__dataent_11924879127625221' #NCAVEO
20        uri=ndgObject.ndgObject(doc)
21        status,xml=ndgRetrieve(uri,self.c)
22        if not status: raise ValueError(xml)
23        self.assertEqual(xml.tree.tag,'dgMetadataRecord')
24       
25    def testNoB(self):
26        ''' Test that we get a sensible error if a NDG-B doc doesn't exist '''
27        doc='badc.nerc.ac.uk__NDG-B0__blah'
28        uri=ndgObject.ndgObject(doc)
29        status,xml=ndgRetrieve(uri,self.c)
30        if status: raise ValueError(' NDG-B0 [%s] should not exist [%s]'%(doc,xml) )
31       
32    def testXMLdif(self):
33        ''' Make sure we can encode and decode at least one DIF properly '''
34        doc='neodc.nerc.ac.uk__DIF__NEODC_NEXTMAP'
35        doc='badc.nerc.ac.uk__DIF__dataent_11738019833217179'
36        uri=ndgObject.ndgObject(doc)
37        status,xml=ndgRetrieve(uri,self.c)
38        if status: s=str(xml)
39
40    def testRemoteGet(self):
41        ''' Attempt a remote get '''
42        doc='www.npm.ac.uk__NDG-B1__data_entity.363'
43        uri=ndgObject.ndgObject(doc)
44        status,xml=ndgRetrieve(uri,self.c,remote=1)
45        if not status: print xml #ie print error message if there is one!
46        self.assertEqual(status,1)
47       
48    def testNumSim(self):
49        '''Get a NumSim document '''
50        doc='badc.nerc.ac.uk__NumSim__HadAM2_CodeBase'
51        doc='badc.nerc.ac.uk__NumSim__HadGEM1_Control_Experiment'
52        uri=ndgObject.ndgObject(doc)
53        status,xml=ndgRetrieve(uri,self.c)
54        self.assertEqual(status,1)
55       
56if __name__=="__main__":
57
58    unittest.main()
Note: See TracBrowser for help on using the repository browser.