Ignore:
Timestamp:
18/02/09 11:33:18 (11 years ago)
Author:
cbyrom
Message:

Move generic 'httpify' method to utilities + adjust utilities method
to retrive default proxy to cope with standard formatting + set this
up on each call to urlopen - since different urls may use different
proxies + tidyup and extend test suite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/unittests/models/teststubb.py

    r4944 r4991  
    22from ndg.common.src.models.stubB import * 
    33from ndg.common.src.models.ndgObject import * 
    4 from ndg.common.src.dal.ndgRetrieve import ndgRetrieve 
     4from ndg.common.src.clients.xmldb.eXist.searchclient import SearchClient 
    55from xml.etree import ElementTree as ET 
    66from ndg.common.src.models.myconfig import myConfig 
    77import ndg.common.unittests.testconstants as tc 
    8      
     8from ndg.common.unittests.testutils import testUtils as tu 
     9from ndg.common.src.models.ndgObject import ndgObject as no 
     10import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 
     11 
    912class TestCase(unittest.TestCase): 
    1013 
    11         def OFFtestDE(self): 
    12             # NB, this requires a valid NDGB1 file to be available 
    13             ''' Test rendering a DataEntity stubB ''' 
    14             doc='badc.nerc.ac.uk__NDG-B1__dataent_EASOE'#dataent_COAPEC' 
    15             xml=self.getit(doc)      
    16             self.doit(xml.tree) 
    17              
    18         def getit(self,doc): 
    19             self.c=myConfig(tc.NDG_CONFIG_FILE) 
    20             uri=ndgObject(doc) 
    21             status,xml=ndgRetrieve(uri,self.c, discovery=0) 
    22             self.assertEqual(status,1) 
    23             xml = ET.fromstring(xml) 
    24             return xml 
    25        
    26         def doit(self,xml): 
    27             x=stubB(xml,self.c) 
    28              
    29       
    30 if __name__=="__main__": 
    31     unittest.main() 
    32              
    33              
     14    def setUp(self): 
     15        ''' 
     16        set up data used in the tests. 
     17        ''' 
     18        self.createdDocs = []    # array to store paths to atoms created - in order to then delete them 
     19        self.utils = tu(tc.EXIST_DBCONFIG_FILE) 
     20        self.c=myConfig(tc.NDG_CONFIG_FILE) 
     21 
     22         
     23    def tearDown(self): 
     24        for path  in self.createdDocs: 
     25            # delete the test file, in case it has been used in a test 
     26            self.utils.deleteDoc(path) 
     27 
     28 
     29    def testDE(self): 
     30        self.createdDocs.append(self.utils.createOldMolesDoc()) 
     31        self.client = SearchClient(dbHostName = tc.EXIST_DB,  
     32                                   configFileName = tc.EXIST_DBCONFIG_FILE) 
     33        doc = self.client.getNDGDoc(tc.VALID_PROVIDER_ID, no.MOLES_DOC_TYPE,  
     34                                    tc.VALID_MOLES_ID, 
     35                                    targetCollection = dc.MOLES_COLLECTION_PATH) 
     36        xml = ET.fromstring(doc) 
     37        x=stubB(xml,self.c) 
     38        # NB, should extend these checks to cover all loaded info 
     39        self.assertEquals([-90.0, -180.0, 180.0, 90.0], x.bbox.boxes[0]) 
     40        self.assertEquals('http://badc.nerc.ac.uk/graphics/logos/small/gostaglb.gif', 
     41                          x.logos[0][1]) 
     42        self.assertTrue(x.parameters.has_key('ATMOSPHERE')) 
Note: See TracChangeset for help on using the changeset viewer.