Ignore:
Timestamp:
16/02/09 10:57:37 (11 years ago)
Author:
cbyrom
Message:

Add new test suite for RESTful client + update various other test classes to cope with changes to client + proxy uses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/unittests/clients/xmldb/eXist/testxmlrpcclient.py

    r4942 r4978  
    77from ndg.common.src.lib.ndgresources import ndgResources 
    88import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 
     9from ndg.common.src.lib.utilities import loadConfigDetails 
    910 
    1011class TestCase(unittest.TestCase):  
     
    1516        set up data used in the tests. 
    1617        ''' 
    17         f=file(tc.EXIST_DBCONFIG_FILE, 'r') 
    18         for line in f.readlines(): 
    19             line = line.strip() 
    20             if not line: 
    21                 continue 
    22             host,userid,password=line.split(' ') 
    23             self.client = XMLRPCClient(host, userid, password) 
    24             break 
    25         f.close()         
     18        userid, password, host = loadConfigDetails(tc.EXIST_DBCONFIG_FILE, tc.EXIST_DB) 
     19        self.client = XMLRPCClient(host, userid, password) 
    2620 
    2721        self.createdAtoms = []    # array to store paths to atoms created - in order to then delete them 
    2822        self.utils = tu(tc.EXIST_DBCONFIG_FILE) 
    2923 
    30  
     24    def testDescribeCollection(self): 
     25        info = self.client.describeCollection(dc.ATOM_COLLECTION_PATH) 
     26        self.assertEqual(dc.ATOM_COLLECTION_PATH, info['name'] + '/') 
     27        self.assertTrue(len(info['collections']) > 0) 
     28        self.assertTrue(info['owner']) 
     29        self.assertTrue(info['created']) 
     30        self.assertTrue(info['group']) 
     31        self.assertTrue(info['permissions']) 
     32         
    3133    def testRunQuery(self): 
    3234        createdAtom = self.utils.createAtomInEXist(tc.xmlString) 
     
    7274        path = atom2.getFullPath() 
    7375        self.client.createCollection(atom2.getDefaultCollectionPath()) 
    74         self.client.storeXML(atom2.toPrettyXML(), path) 
     76        self.client.createDoc(atom2.toPrettyXML(), path) 
    7577        self.createdAtoms.append(path) 
    7678         
     
    9597        path = atom2.getFullPath() 
    9698        self.client.createCollection(atom2.getDefaultCollectionPath()) 
    97         self.client.storeXML(atom2.toPrettyXML(), path) 
     99        self.client.createDoc(atom2.toPrettyXML(), path) 
    98100        self.createdAtoms.append(path) 
    99101         
     
    122124        path = atom2.getFullPath() 
    123125        self.client.createCollection(atom2.getDefaultCollectionPath()) 
    124         self.client.storeXML(atom2.toPrettyXML(), path) 
     126        self.client.createDoc(atom2.toPrettyXML(), path) 
    125127        self.createdAtoms.append(path) 
    126128         
     
    157159        xquery = res.createXQuery('atom', dc.ATOM_COLLECTION_PATH, "", tc.datasetID) 
    158160        docs = self.client.runQuery(xquery, noResults = 0) 
    159         self.assertEqual(1, len(docs)) 
     161        self.assertEqual(0, len(docs)) 
    160162 
    161163 
     
    173175        path = atom2.getFullPath() 
    174176        self.client.createCollection(atom2.getDefaultCollectionPath()) 
    175         self.client.storeXML(atom2.toPrettyXML(), path) 
     177        self.client.createDoc(atom2.toPrettyXML(), path) 
    176178        self.createdAtoms.append(path) 
    177179         
     
    217219        self.assertFalse(self.client.removeCollection(tc.TEST_COLLECTION_PATH)) 
    218220     
    219     def testStoreXML(self): 
    220         self.assertTrue(self.client.storeXML(tc.xmlString, tc.TEST_FILE_NAME)) 
     221    def testCreateDoc(self): 
     222        self.assertTrue(self.client.createDoc(tc.xmlString, tc.TEST_FILE_NAME)) 
    221223        self.assertTrue(self.client.removeDoc(tc.TEST_FILE_NAME)) 
    222224     
    223     def testStoreXMLWithoutOverwrite(self): 
    224         self.assertTrue(self.client.storeXML(tc.xmlString, tc.TEST_FILE_NAME)) 
    225         self.assertRaises(xmlrpclib.Fault, self.client.storeXML, tc.xmlString, tc.TEST_FILE_NAME) 
     225    def testCreateDocWithoutOverwrite(self): 
     226        self.assertTrue(self.client.createDoc(tc.xmlString, tc.TEST_FILE_NAME)) 
     227        self.assertRaises(xmlrpclib.Fault, self.client.createDoc, tc.xmlString, tc.TEST_FILE_NAME) 
    226228        self.assertTrue(self.client.removeDoc(tc.TEST_FILE_NAME)) 
    227229     
    228     def testStoreXMLWithOverwrite(self): 
    229         self.assertTrue(self.client.storeXML(tc.xmlString, tc.TEST_FILE_NAME)) 
    230         self.assertTrue(self.client.storeXML(tc.xmlString, tc.TEST_FILE_NAME, overwrite=1)) 
     230    def testCreateDocWithOverwrite(self): 
     231        self.assertTrue(self.client.createDoc(tc.xmlString, tc.TEST_FILE_NAME)) 
     232        self.assertTrue(self.client.createDoc(tc.xmlString, tc.TEST_FILE_NAME, overwrite=1)) 
    231233        self.assertTrue(self.client.removeDoc(tc.TEST_FILE_NAME)) 
    232234 
    233235    def testRemoveDoc(self): 
    234         self.assertTrue(self.client.storeXML(tc.xmlString, tc.TEST_FILE_NAME)) 
     236        self.assertTrue(self.client.createDoc(tc.xmlString, tc.TEST_FILE_NAME)) 
    235237        self.assertTrue(self.client.removeDoc(tc.TEST_FILE_NAME)) 
    236238 
    237239    def testInvalidRemoveDoc(self): 
    238         self.assertRaises(xmlrpclib.Fault, self.client.removeDoc, tc.TEST_FILE_NAME) 
     240        self.assertFalse(self.client.removeDoc(tc.TEST_FILE_NAME)) 
    239241 
    240242         
Note: See TracChangeset for help on using the changeset viewer.