source: ndgCommon/trunk/ndg/common/unittests/models/teststubb.py @ 4991

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/unittests/models/teststubb.py@4991
Revision 4991, 1.8 KB checked in by cbyrom, 11 years ago (diff)

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.

RevLine 
[4793]1import unittest
2from ndg.common.src.models.stubB import *
3from ndg.common.src.models.ndgObject import *
[4991]4from ndg.common.src.clients.xmldb.eXist.searchclient import SearchClient
[4944]5from xml.etree import ElementTree as ET
[4793]6from ndg.common.src.models.myconfig import myConfig
7import ndg.common.unittests.testconstants as tc
[4991]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
[4793]12class TestCase(unittest.TestCase):
13
[4991]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 TracBrowser for help on using the repository browser.