source: ndgCommon/trunk/ndg/common/unittests/clients/http/testvocabserverclient.py @ 4990

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

Split out the remaining code in DocumentRetrieve? into a new clients
package - providing simple http clients:

generichttpclient - which allows simple GET requests on urls
httpsearchclient - which implements the search interface (partially) - allowing the getNDGDoc method using RESTful interfaces
vocabserverclient - which allows lookup of vocab search terms.

Remove DocumentRetrieve? and associated code + add new test suite for
new package.

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.clients.http.vocabserverclient import VocabServerClient
17import ndg.common.unittests.testconstants as tc
18from ndg.common.src.models.myconfig import myConfig
19
20class TestCase(unittest.TestCase): 
21
22    def setUp(self):
23        '''
24        set up data used in the tests.
25        '''
26        self.cf = myConfig(tc.NDG_CONFIG_FILE)
27        self.client = VocabServerClient(proxyServer = self.cf.get('DEFAULT','proxyServer'))
28
29   
30    def testVocabServerClient1(self):
31        res = self.client.getRelated('rain')
32        self.assertEquals(res[1][0], 'rain')
33
34   
35    def testVocabServerClient2(self):
36        res = self.client.getRelated('snow')
37        self.assertEquals(res[1][0], 'snow')
38
39       
40    def testInvalidVocabServer(self):
41        res = self.client.getRelated('rainxxxxx')
42        self.assertEquals([], res[0])
43        self.assertEquals([], res[1])
44        self.assertEquals(3, len(res))
45       
Note: See TracBrowser for help on using the repository browser.