Changeset 5117 for ndgCommon


Ignore:
Timestamp:
18/03/09 17:14:21 (11 years ago)
Author:
cbyrom
Message:

Move VocabList? model to the VocabTermEditor? project, since this is
where it sits most comfortably. Adjust getList method of vocabserverclient to return its data in an elementtree instead of
VocabList? to avoid codebase pollution + move tests + update tests
to cope with loss of VocabList?.

Location:
ndgCommon/trunk/ndg/common
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/http/vocabserverclient.py

    r5083 r5117  
    77from xml.etree import ElementTree as ET 
    88from generichttpclient import GenericHTTPClient 
    9 from ndg.common.src.models.vocablist import VocabList 
    109from ndg.common.src.models.ndgObject import ndgObject 
    1110from ndg.common.src.lib.utilities import httpify 
     
    7271        @raise SystemError if the service returns an error 
    7372        @raise IOError if an invalid listKey is provided 
    74         @return VocabList with all data loaded - or None, if nothing retrieved 
     73        @raise SystemError if returned doc features an error 
     74        @return ElementTree with all data loaded - or None, if nothing retrieved 
    7575        ''' 
    7676        logging.debug("Retrieving list info for key, '%s'" %listKey) 
     
    7878        doc = self.readURL(url) 
    7979        et = ET.fromstring(doc) 
    80          
    81         list = VocabList(et = et) 
     80        error = et.findtext('{%s}error' %ndgObject.VOCAB_NS) 
    8281         
    8382        # check for errors 
    84         if list.error != 'false': 
    85             raise SystemError("Problem occurred whilst looking up vocab data: %s" %list.error) 
     83        if error != 'false': 
     84            raise SystemError("Problem occurred whilst looking up vocab data: %s" %error) 
    8685         
    8786        logging.debug("- returning info in Elementtree object") 
    88         return list 
     87        return et 
    8988     
    9089     
  • ndgCommon/trunk/ndg/common/unittests/clients/http/testvocabserverclient.py

    r5083 r5117  
    1414 
    1515import logging, unittest 
     16from xml.etree import cElementTree as ET 
     17from ndg.common.src.models.ndgObject import ndgObject 
    1618from ndg.common.src.clients.http.vocabserverclient import VocabServerClient  
    1719import ndg.common.unittests.testconstants as tc 
    1820from ndg.common.src.models.myconfig import myConfig 
    19 from ndg.common.src.models.vocablist import VocabList 
    2021 
    2122class TestVocabServerClient(unittest.TestCase):  
     
    4647         
    4748    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) 
     49        et = self.client.getList(tc.STANDARD_NAMES_LIST) 
     50        el = ET.ElementTree() 
     51        self.assertTrue(isinstance(et, type(el))) 
     52        self.assertEqual('false', et.findtext('{%s}error' %ndgObject.VOCAB_NS)) 
     53        self.assertTrue(len(et.findall('{%s}codeTableRecord' %ndgObject.VOCAB_NS)) > 0) 
    5254         
    5355    def testInvalidGetList(self): 
  • ndgCommon/trunk/ndg/common/unittests/models/testcodetablerecord.py

    r5097 r5117  
    88from ndg.common.src.models.codetablerecord import CodeTableRecord 
    99from ndg.common.src.clients.http.vocabserverclient import VocabServerClient  
    10 from ndg.common.src.models.vocablist import VocabList  
    1110import ndg.common.unittests.testconstants as tc 
    1211from ndg.common.src.models.myconfig import myConfig 
     
    5251                                  %(self.client.path, tc.STANDARD_NAMES_LIST)) 
    5352        et = ET.fromstring(doc) 
    54         vl = VocabList(et = et) 
    55                                    
    56         self.ctr = vl.getVocabTermDataByEntryKey(tc.STANDARD_NAME_TERM) 
     53        recordElements = et.findall('{%s}codeTableRecord' %ndgObject.VOCAB_NS) 
     54        records = [] 
     55        for record in recordElements: 
     56            records.append(CodeTableRecord(et = record)) 
     57      
     58        self.ctr = None 
     59        for record in records: 
     60            if record.entryKey == tc.STANDARD_NAME_TERM: 
     61                self.ctr = record 
     62        self.assertNotEquals(None, self.ctr) 
    5763 
    5864        self.assertEquals(tc.SN_MOD_DATE, self.ctr.entryTermLastMod,  
Note: See TracChangeset for help on using the changeset viewer.