Ignore:
Timestamp:
26/03/07 22:21:36 (14 years ago)
Author:
lawrence
Message:

Sundry testcases plus a a bug fix for ticket:666 ... it's done, but I
don't like this bugfix because it shows that I don't really understand
unicode properly. Need to revisit unicode again ... later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/renderService.py

    r2296 r2330  
    44        self.config=config 
    55    def get(self,service): 
    6         print 'BNL',service 
    76        if service.contentType.upper() not in ['NDG_A_SERVICE','NDG_B_SERVICE','DISCOVERY']: 
    87            section='RELATED' 
     
    2221            description=service.description+' Note that NDG services are not currently enabled.' 
    2322        else: 
    24             description=service.description 
    25         return ('<a href="%s" title="%s"><img src="%s" alt="%s"/></a>'%( 
     23            #this is a bug fix, and it worries me that I had to do it ... I don't understand why 
     24            #ideally this should apply to all the attributes of a DIF ...  
     25            description=service.description.decode('utf-8') 
     26        x=('<a href="%s" title="%s"><img src="%s" alt="%s"/></a>'%( 
    2627                url,description,icon,alt),description) 
    27  
     28        return x 
    2829 
    2930import unittest 
     
    3132from Utilities import myConfig 
    3233 
     34configFile='examples/example.config' 
    3335class TestCase(unittest.TestCase): 
    3436 
    3537    def testDIFBinding(self): 
    3638        ''' Tests a DIF binding does the right thing ''' 
    37         configFile='examples/example.config' 
     39         
    3840        s=DIFService('NDG_B_SERVICE','grid.bodc.rl.ac.uk','The NDG service for browsing metadata') 
    3941        c=myConfig(configFile) 
     
    4143        print x.get(s) 
    4244         
     45    def testOdditity(self): 
     46        '''Tests a specific record for misbehaviour''' 
     47        from ndgRetrieve import ndgRetrieve 
     48        from DIF import DIF 
     49        from ndgObject import ndgObject 
     50        testURI='grid.bodc.nerc.ac.uk:DIF:EDMED1048008' 
     51        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'DIF','type':'xml','original':'1'} 
     52        retriever=ndgRetrieve('./') 
     53        ctype,r=retriever._present(inputs,'text/xml') 
     54        con=myConfig(configFile) 
     55        obj=ndgObject(testURI) 
     56        obj.setConfig(con) 
     57        d=DIF(r,ndgObject=obj) 
     58        for s in d.services: 
     59            h=renderService(con) 
     60            print h.get(s) 
     61 
     62         
    4363if __name__=="__main__": 
    4464    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.