Changeset 3127
- Timestamp:
- 06/12/07 16:58:44 (13 years ago)
- Location:
- exist/trunk
- Files:
-
- 1 added
- 7 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
exist/trunk/python/ndgUtils/DocumentRetrieve.py
r3125 r3127 65 65 66 66 #now get the real xquery 67 xq =self.xq.actual(xqtype,targetCollection,repository,localID)67 xquery=self.xq.actual(xqtype,targetCollection,repository,localID) 68 68 69 69 try: -
exist/trunk/python/ndgUtils/ndgObject.py
r3125 r3127 108 108 ''' Actually retrieve an ORIGINAL xml record corresponding to an ndg URI ''' 109 109 if self.config is None: return None 110 status,xmlh=ndgRetrieve(self .uri,self.config)110 status,xmlh=ndgRetrieve(self,self.config) 111 111 if status: 112 112 return xmlh.xmls -
exist/trunk/python/ndgUtils/ndgRetrieve.py
r3125 r3127 20 20 # actual exist repository er. 21 21 # I'm sure this can be cleaned up further :-) 22 try:23 24 25 26 except:27 raise ValueError,'Config file not available or is incomplete'22 #try: 23 r=config.get('NDG_B_SERVICE',uri.repository) 24 sr=config.get('DEFAULT','repository') 25 er=config.get('NDG_EXIST',uri.repository) 26 #except: 27 # raise ValueError,'Config file not available or is incomplete' 28 28 if r<> sr: 29 29 if not remote: -
exist/trunk/python/ndgUtils/ndgSearch.py
r3093 r3127 194 194 return results 195 195 196 def get(self,repository,schema,localID,format=' original',targetCollection=None):196 def get(self,repository,schema,localID,format='DIF',**kw): 197 197 ''' Obtain a document via it's NDG id split up ''' 198 198 #nb argument targetCollection is here to provide same API as exist xmlrpc interface … … 202 202 203 203 204 import unittest 205 206 class TestCase(unittest.TestCase): 207 208 def testSearch(self): 209 ''' Test fundamental search capability ''' 210 term='temperature' 211 s=ndgSearch() 212 howmany=10 213 docs=s.search(term,start=1,howmany=howmany) 214 print 'Asked for ',howmany,' documents (there were %s hits):'%s.hits 215 print s.documents 216 217 def testgetLabelledDocs(self): 218 ''' Test returning of labelled documents ''' 219 term='CD97' 220 s=ndgSearch() 221 r=s.search(term) 222 print s.status 223 print s.documents 224 output=s.getLabelledDocs() 225 226 def testNoReturn(self): 227 ''' Tests a search return with (hopefully nothing to be found)''' 228 term='xpabnl' 229 s=ndgSearch() 230 r=s.search(term) 231 print 'Hopefully this is zero: if not, expect the NoReturn test to fail:',s.hits 232 output=s.getLabelledDocs() 233 self.assertEqual(len(output),0) 234 235 def testGetDoc(self): 236 ''' Test obtaining a specific document which had better exist ''' 237 doc='noc.soton.ac.uk__DIF__NOCSDAT100.xml' 238 #doc='ndg.noc.soton.ac.uk__DIF__NOCSDAT274.xml' 239 s=ndgSearch() 240 r=s.getDoc(doc) 241 242 def testSequence(self): 243 ''' Tests that repeated searches work and can support zero responses in the middle ''' 244 # this was a bug we found and needed a test case for 245 s=ndgSearch() 246 term='CD97' # hopefully just get a couple of hits for now. 247 r=s.search(term) 248 print s.hits 249 #if we uncomment this it used to break, and not if uncommented, now it seems ok... 250 output=s.getLabelledDocs() 251 #this failed as well, and we isolated the dependency in the previous call to this one. 252 #res=s.getAllDocs() 253 term='xpabnl' 254 r=s.search(term) 255 print s.hits 256 print 'Hopefully this is also zero: if not, expect the Sequence test to fail:',s.hits 257 258 def testGet(self): 259 ''' Tests getting via uri components ''' 260 (r,s,l)='neodc.nerc.ac.uk','DIF','NEODC_ARSF_ATM_DAED' 261 ss=ndgSearch() 262 x=ss.get(r,s,l,format='DC') 263 264 def testFailedGet(self): 265 doc='abc' 266 s=ndgSearch() 267 r=s.getDoc(doc) 268 assert 'Error' in r 269 270 if __name__=="__main__": 271 unittest.main() 204 -
exist/trunk/python/ndgUtils/test_ndgRetrieve.py
r3125 r3127 21 21 status,xml=ndgRetrieve(uri,self.c) 22 22 if not status: raise ValueError(xml) 23 self.assertEqual(xml.tree.tag,'dgMetadataRecord') 23 24 24 25 def testNoB(self): -
exist/trunk/python/ndgUtils/test_xqueries.py
r3125 r3127 3 3 from eXistInterface import ndg_eXist 4 4 from ndgObject import ndgObject 5 import ConfigParser 5 6 6 7 class TestCase(unittest.TestCase): 7 8 8 def setUp(self): 9 def setUp(self): 10 f='test.config' 11 self.c=ConfigParser.ConfigParser() 12 self.c.read(f) 9 13 self.xq=ndgXqueries.ndgXqueries() 10 14 self.xmldb=ndg_eXist(db='glue.badc.rl.ac.uk') 11 15 self.testDElist=['badc.nerc.ac.uk__NDG-B1__dataent_COAPEC'] 12 16 13 def test_moles Query(self):14 ''' Tests the moles query'''15 entity=self.testDElist[0]16 n=ndgObject(entity)17 r=n.get()17 def test_moles2difRoundTrip(self): 18 ''' Tests the moles 2 dif round tripping ''' 19 moles1=self.testDElist[0] 20 dif1=moles1.replace('NDG-B1','DIF') 21 18 22 19 23 -
exist/trunk/python/ndgUtils/wsdlUse
r2938 r3127 1 wsdl2py --lazy -b -f $1 1 wsdl2py -b -f $1 2 # might need -lazy for vocab server -
exist/trunk/python/setup.cfg
r3110 r3127 1 1 [egg_info] 2 2 tag_build = .dev 3 tag_svn_revision = true -
exist/trunk/python/setup.py
r3125 r3127 5 5 setup( 6 6 name='ndgUtils', 7 version='0.1 ',7 version='0.1.0', 8 8 packages=find_packages(), 9 9 test_suite='nose.collector', 10 package_data = {'ndgUtils':'xquery/*.xq'} 10 package_data = {'ndgUtils':['xquery/*.xq']}, 11 author = 'Bryan Lawrence', 12 license = 'LGPL', 13 description = 'NDG utilities for metadata search and extraction', 14 long_description=''' 15 This is a package of utilities for manipulating metadata 16 documents conforming to NERC DataGrid specifications, and 17 held in eXist databases. Utilities to manipulate the 18 NERC DataGrid public SOAP search interface are also 19 included ''' 11 20 )
Note: See TracChangeset
for help on using the changeset viewer.