Changeset 4942


Ignore:
Timestamp:
11/02/09 09:24:39 (11 years ago)
Author:
cbyrom
Message:

Replace old eXist connector tests with tests based on the new clients
+ extend and fix this wherever necessary.

Location:
ndgCommon/trunk/ndg/common/unittests/clients/xmldb/eXist
Files:
5 added
4 deleted
1 copied

Legend:

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

    r4849 r4942  
    11''' 
    2 A test class for the EXistInitialiser module. 
     2A test class for the AtomDBInitialiser module. 
    33 
    44@author C Byrom, Tessella Jan 2009 
    55''' 
    66import unittest, time, logging 
    7 from ndg.common.src.lib.existinitialiser import EXistInitialiser as ei 
     7from ndg.common.src.clients.xmldb.eXist.atomdbinitialiser import AtomDBInitialiser as ai 
    88import ndg.common.unittests.testconstants as tc 
    99from ndg.common.unittests.testutils import testUtils as tu 
    10 from ndg.common.src.clients.xmldb.eXist.eXistConnector import eXistConnector as ec 
     10import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 
    1111 
    12 class testEXistInitialiser(unittest.TestCase): 
     12class testAtomDBInitialiser(unittest.TestCase): 
    1313     
    1414    def setUp(self): 
     
    1717        ''' 
    1818        self.utils = tu(tc.EXIST_DBCONFIG_FILE) 
    19         self.ei = ei(self.utils.dbc) 
     19        self.ai = ai(self.utils.ac) 
    2020        logging.basicConfig(level=logging.DEBUG, 
    2121                        format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s %(message)s') 
     
    2323 
    2424    def testSetUpIndexes(self): 
    25         fileName = self.utils.dbc.xmldb.xq.indexes.keys()[0] 
     25        fileName = self.utils.ac.resources.indexes.keys()[0] 
    2626        pathName = fileName.replace('_', '/') 
    27         pathName = ec.EXIST_CONFIG_PATH + pathName.replace('.xconf', '') + '/' + fileName 
     27        pathName = dc.EXIST_CONFIG_PATH + pathName.replace('.xconf', '') + '/' + fileName 
    2828        # firstly, remove this file, if it exists 
    29         if not self.utils.dbc.isNewEXistFile(pathName): 
    30             self.utils.dbc.deleteEXistFile(pathName) 
    31         self.assertEquals(self.utils.dbc.isNewEXistFile(pathName), True) 
     29        if not self.utils.ac.isNewDoc(pathName): 
     30            self.utils.ac.deleteDoc(pathName) 
     31        self.assertEquals(self.utils.ac.isNewDoc(pathName), True) 
    3232         
    3333        # now run the set up 
    34         self.ei._EXistInitialiser__setUpIndexes() 
     34        self.ai._AtomDBInitialiser__setUpIndexes() 
    3535         
    3636        # now check it exists 
    37         self.assertEquals(self.utils.dbc.isNewEXistFile(pathName), False) 
     37        self.assertFalse(self.utils.ac.isNewDoc(pathName)) 
    3838 
    3939 
    4040    def testSetUpEXistCollections(self): 
    4141        try: 
    42             self.ei._EXistInitialiser__setUpEXistAtomCollections() 
    43         except: 
     42            self.utils.ac.client.removeCollection(dc.ATOM_COLLECTION_PATH) 
     43            self.assertTrue(self.utils.ac.isNewCollection(dc.ATOM_COLLECTION_PATH)) 
     44 
     45            self.ai._AtomDBInitialiser__setUpEXistAtomCollections() 
     46            self.assertFalse(self.utils.ac.isNewCollection(dc.ATOM_COLLECTION_PATH)) 
     47        except Exception, e: 
    4448            self.fail("Should not have thrown an exception") 
    4549 
    4650 
    4751    def testAddAtomSchema(self): 
    48         fileName = self.utils.dbc.xmldb.xq.xsd.keys()[0] + '.xsd' 
    49         pathName = ec.SCHEMATA_COLLECTION_PATH + '/' + fileName 
     52        fileName = self.utils.ac.resources.xsd.keys()[0] + '.xsd' 
     53        pathName = dc.SCHEMAS_COLLECTION_PATH + '/' + fileName 
    5054        # firstly, remove this file, if it exists 
    51         if not self.utils.dbc.isNewEXistFile(pathName): 
    52             self.utils.dbc.deleteEXistFile(pathName) 
     55        if not self.utils.ac.isNewDoc(pathName): 
     56            self.utils.ac.deleteDoc(pathName) 
    5357            time.sleep(2) 
    5458 
    55         self.assertEquals(self.utils.dbc.isNewEXistFile(pathName), True) 
     59        self.assertEquals(self.utils.ac.isNewDoc(pathName), True) 
    5660 
    57         self.ei._EXistInitialiser__addAtomSchema() 
     61        self.ai._AtomDBInitialiser__addAtomSchema() 
    5862         
    5963        # now check it exists 
    60         self.assertEquals(self.utils.dbc.isNewEXistFile(pathName), False) 
     64        self.assertEquals(self.utils.ac.isNewDoc(pathName), False) 
    6165 
    6266         
Note: See TracChangeset for help on using the changeset viewer.