Changeset 3127 for exist/trunk


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.

Location:
exist/trunk
Files:
1 added
7 edited
4 copied

Legend:

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

    r3125 r3127  
    6565             
    6666            #now get the real xquery 
    67             xq=self.xq.actual(xqtype,targetCollection,repository,localID) 
     67            xquery=self.xq.actual(xqtype,targetCollection,repository,localID) 
    6868             
    6969            try: 
  • exist/trunk/python/ndgUtils/ndgObject.py

    r3125 r3127  
    108108        ''' Actually retrieve an ORIGINAL xml record corresponding to an ndg URI ''' 
    109109        if self.config is None: return None 
    110         status,xmlh=ndgRetrieve(self.uri,self.config) 
     110        status,xmlh=ndgRetrieve(self,self.config) 
    111111        if status: 
    112112            return xmlh.xmls 
  • exist/trunk/python/ndgUtils/ndgRetrieve.py

    r3125 r3127  
    2020        #    actual exist repository er. 
    2121        #    I'm sure this can be cleaned up further :-) 
    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' 
     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' 
    2828        if r<> sr: 
    2929            if not remote: 
  • 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 
  • exist/trunk/python/ndgUtils/test_ndgRetrieve.py

    r3125 r3127  
    2121        status,xml=ndgRetrieve(uri,self.c) 
    2222        if not status: raise ValueError(xml) 
     23        self.assertEqual(xml.tree.tag,'dgMetadataRecord') 
    2324         
    2425    def testNoB(self): 
  • exist/trunk/python/ndgUtils/test_xqueries.py

    r3125 r3127  
    33from eXistInterface import ndg_eXist 
    44from ndgObject import ndgObject 
     5import ConfigParser 
    56 
    67class TestCase(unittest.TestCase): 
    78     
    8     def setUp(self): 
     9    def setUp(self):  
     10        f='test.config' 
     11        self.c=ConfigParser.ConfigParser() 
     12        self.c.read(f) 
    913        self.xq=ndgXqueries.ndgXqueries() 
    1014        self.xmldb=ndg_eXist(db='glue.badc.rl.ac.uk') 
    1115        self.testDElist=['badc.nerc.ac.uk__NDG-B1__dataent_COAPEC'] 
    1216         
    13     def test_molesQuery(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         
    1822         
    1923         
  • exist/trunk/python/ndgUtils/wsdlUse

    r2938 r3127  
    1 wsdl2py --lazy -b -f $1 
     1wsdl2py -b -f $1 
     2# might need -lazy for vocab server 
  • exist/trunk/python/setup.cfg

    r3110 r3127  
    11[egg_info] 
    22tag_build = .dev 
     3tag_svn_revision = true 
  • exist/trunk/python/setup.py

    r3125 r3127  
    55setup( 
    66        name='ndgUtils', 
    7         version='0.1', 
     7        version='0.1.0', 
    88        packages=find_packages(), 
    99        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=''' 
     15This is a package of utilities for manipulating metadata 
     16documents conforming to NERC DataGrid specifications, and 
     17held in eXist databases. Utilities to manipulate the 
     18NERC DataGrid public SOAP search interface are also  
     19included ''' 
    1120) 
Note: See TracChangeset for help on using the changeset viewer.