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

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

Extend vocabserver client, providing a method to retrieve a vocab list
+ add new data models to handle the returned info + update interface
details and usage + add new file utility method for creating
directories + extend tests.

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
19from ndg.common.src.models.vocablist import VocabList
20
21class TestVocabServerClient(unittest.TestCase): 
22
23    def setUp(self):
24        '''
25        set up data used in the tests.
26        '''
27        self.cf = myConfig(tc.NDG_CONFIG_FILE)
28        self.client = VocabServerClient(proxyServer = self.cf.get('DEFAULT','proxyServer'))
29
30   
31    def testGetRelated1(self):
32        res = self.client.getRelated('rain')
33        self.assertEquals(res[1][0], 'rain')
34
35   
36    def testGetRelated2(self):
37        res = self.client.getRelated('snow')
38        self.assertEquals(res[1][0], 'snow')
39
40       
41    def testInvalidGetRelated(self):
42        res = self.client.getRelated('rainxxxxx')
43        self.assertEquals([], res[0])
44        self.assertEquals([], res[1])
45        self.assertEquals(3, len(res))
46       
47    def testGetList(self):
48        list = self.client.getList(tc.STANDARD_NAMES_LIST)
49        self.assertTrue(isinstance(list, VocabList))
50        self.assertEqual('false', list.error)
51        self.assertTrue(len(list.records) > 0)
52       
53    def testInvalidGetList(self):
54        self.assertRaises(IOError, self.client.getList, tc.STANDARD_NAMES_LIST + 'blah')
55       
56       
Note: See TracBrowser for help on using the repository browser.