Ignore:
Timestamp:
06/12/07 16:58:44 (12 years ago)
Author:
lawrence
Message:

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.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/ndgSearch.py

    r3093 r3127  
    194194        return results 
    195195         
    196     def get(self,repository,schema,localID,format='original',targetCollection=None): 
     196    def get(self,repository,schema,localID,format='DIF',**kw): 
    197197        ''' Obtain a document via it's NDG id split up ''' 
    198198        #nb argument targetCollection is here to provide same API as exist xmlrpc interface 
     
    202202         
    203203         
    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 
Note: See TracChangeset for help on using the changeset viewer.