source: ndgCommon/trunk/ndg/common/unittests/clients/http/testhttpsearchclient.py @ 5012

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/unittests/clients/http/testhttpsearchclient.py@5012
Revision 5012, 2.0 KB checked in by cbyrom, 10 years ago (diff)

Various tidy ups and fixes to the test codebase - including the removal
of uneccesary files + simplify the test constants.

Line 
1"""
2Test cases for the VocabServerClient class
3
4NERC Data Grid Project
5"""
6__author__ = "C Byrom - Tessella"
7__date__ = "17/02/09"
8__copyright__ = "(C) 2008 STFC & NERC"
9__license__ = \
10"""This software may be distributed under the terms of the Q Public
11License, version 1.0 or later."""
12__contact__ = "b.n.lawrence@rl.ac.uk"
13__revision__ = '$Id: $'
14
15import logging, unittest
16from ndg.common.src.models.ndgObject import ndgObject as no
17from ndg.common.src.clients.http.httpsearchclient import HTTPSearchClient
18import ndg.common.unittests.testconstants as tc
19from ndg.common.unittests.testutils import testUtils as tu
20from ndg.common.src.models.myconfig import myConfig
21
22class TestCase(unittest.TestCase): 
23
24    def setUp(self):
25        '''
26        set up data used in the tests.
27        NB, this test requires a valid MILK browse service to be available
28        '''
29        self.cf = myConfig(tc.NDG_CONFIG_FILE)
30        proxyServer = self.cf.get('DEFAULT', 'proxyServer')
31        browseRepository = self.cf.get('NDG_B_SERVICE', tc.VALID_PROVIDER_ID)
32        self.client = HTTPSearchClient(browseRepository,#'http://localhost:5000',
33                                       proxyServer = proxyServer)
34        self.createdAtoms = []    # array to store paths to atoms created - in order to then delete them
35        self.utils = tu(tc.EXIST_DBCONFIG_FILE)
36        createdAtom = self.utils.createAtomInEXist(tc.xmlString)
37        self.createdAtoms.append(createdAtom.getFullPath())
38       
39    def tearDown(self):
40        for path  in self.createdAtoms:
41            # delete the test file, in case it has been used in a test
42            self.utils.deleteDoc(path)
43
44   
45    def testGetNDGDoc(self):
46        n = no(tc.ndgURI)
47        doc = self.client.getNDGDoc(n.repository,n.schema,n.localID)
48        self.assertNotEquals(doc.find(tc.id), -1)
49
50       
51    def testInvalidNdgHTTP(self):
52        n = no(tc.INVALID_NDG_URL)
53        self.assertRaises(IOError, self.client.getNDGDoc, n.repository,n.schema,n.localID)
Note: See TracBrowser for help on using the repository browser.