Changeset 4783


Ignore:
Timestamp:
12/01/09 10:12:00 (11 years ago)
Author:
cbyrom
Message:

Extend test suites to test new feed and DIF creation functionality.

Location:
exist/trunk/python/ndgutilstests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgutilstests/lib/testexistdbclient.py

    r4696 r4783  
    1111from ndgUtils.ndgXqueries import ndgXqueries 
    1212from ndgUtils.models.Atom import Atom 
     13from ndgUtils.models import AtomState 
    1314from ndgUtils.models.vocabtermdata import VocabTermData as VTD 
    1415import ndgutilstests.testconstants as tc 
     
    232233        self.assertNotEquals(0, len(ids)) 
    233234        self.assertNotEquals({}, ids) 
     235             
     236    def testRunAsynchAtomPublish(self): 
     237        atom = self.utils.createAtom(tc.xmlString) 
     238        atom.state = AtomState.PUBLISHED_STATE 
     239        providerCollection = ec.PROVIDER_FEED_PATH + atom.ME.providerID 
     240        if self.utils.dbc.isNewEXistCollection(providerCollection): 
     241            self.utils.dbc.createCollections([providerCollection]) 
     242            self.utils.dbc.feedClient.createAtomFeed(providerCollection, 
     243                           self.utils.dbc.feedClient.PROVIDERLEVEL_ATOM_FEED_TITLE %atom.ME.providerID) 
     244        self.utils.dbc.runAsynchAtomPublish(atom) 
    234245 
    235246    def testRestoreBackup(self): 
     
    246257    def testInvalidRestoreBackup(self): 
    247258        self.assertRaises(SystemError, self.utils.dbc.restoreBackup, self.DUMMY_COLLECTION) 
     259 
     260    def testCreateDIFDocumentFromAtom(self): 
     261        atom = self.utils.createAtom(tc.xmlString) 
     262        atom.atomTypeID = VTD.DE_TERM 
     263        atom = self.utils.dbc.createAtomInExist(atom) 
     264        self.utils.dbc.createDIFDocumentFromAtom(atom) 
     265        self.utils.dbc.deleteAtomInExist(atom) 
    248266         
    249267    def tearDown(self): 
  • exist/trunk/python/ndgutilstests/lib/testexistdbfeedclient.py

    r4758 r4783  
    2929        set up data used in the tests. 
    3030        ''' 
    31         self.tidyUp = False    #     switch to indicate to tearDown that we need to delete the created eXist file 
     31        self.createdAtoms = []    # array to store paths to atoms created - in order to then delete them 
    3232        self.utils = tu(tc.DBCONFIG_FILE) 
    3333        self.feedClient = feedClient(self.utils.dbc.xmldb.auth, 
     
    3838        try: 
    3939            self.feedClient.createAtomFeed(self.VALID_COLLECTION_PATH,  
    40                                           self.feedClient.ATOM_FEED_TITLE) 
     40                                          self.feedClient.TOPLEVEL_ATOM_FEED_TITLE) 
    4141        except: 
    4242            self.fail("Should not have thrown an exception") 
     
    4545        try: 
    4646            self.feedClient.createAtomFeed(self.INVALID_PATH,  
    47                                           self.feedClient.ATOM_FEED_TITLE) 
     47                                          self.feedClient.TOPLEVEL_ATOM_FEED_TITLE) 
    4848            self.fail("Should have thrown an exception") 
    4949        except FeedClientError, fce: 
     
    5353         
    5454    def testValidGetRESTfulData(self): 
    55         self.tidyUp = True 
    5655        self.assertEquals(self.utils.dbc.createEXistFile(data.testdata.xmlString, self.VALID_COLLECTION_PATH, self.VALID_FILE), True) 
    57         self.assertNotEquals(None, self.feedClient.getRESTfulData(self.VALID_FILE_PATH)) 
     56        self.createdAtoms.append(self.VALID_FILE_PATH) 
     57        doc = self.feedClient.getRESTfulData(self.VALID_FILE_PATH) 
     58        self.assertNotEquals(None, doc) 
    5859         
    5960    def testInvalidGetRESTfulData(self): 
     
    7980    def testCreateAtomFeedEntry(self): 
    8081        try: 
     82            self.tidyUp = True 
    8183            atom = tu(tc.DBCONFIG_FILE).createAtom(tc.xmlString) 
    8284            self.feedClient.createAtomFeedEntry(self.VALID_COLLECTION_PATH, 
    8385                                                atom)  
     86        except: 
     87            self.fail("Should not have thrown an exception") 
     88 
     89 
     90    def testCreateAtomFeedEntryWithIsDIFRecordKeyword(self): 
     91        try: 
     92            self.tidyUp = True 
     93            atom = tu(tc.DBCONFIG_FILE).createAtom(tc.xmlString) 
     94            self.feedClient.createAtomFeedEntry(self.VALID_COLLECTION_PATH, 
     95                                                atom, isDIFRecord=True)  
    8496        except: 
    8597            self.fail("Should not have thrown an exception") 
     
    111123            self.fail("Should have thrown a FeedClientError exception") 
    112124 
     125 
     126    def testSetupBasicFeeds(self): 
     127        try: 
     128            feed = self.feedClient.setupBasicFeeds() 
     129        except: 
     130            self.fail("Should not have thrown an exception") 
     131         
     132 
    113133    def tearDown(self): 
    114         if self.tidyUp: 
     134        for path  in self.createdAtoms: 
    115135            # delete the test file, in case it has been used in a test 
    116             self.utils.dbc.deleteEXistFile(self.VALID_FILE_PATH) 
     136            self.utils.deleteAtomInExist(path) 
    117137 
    118138if __name__ == '__main__': 
  • exist/trunk/python/ndgutilstests/models/testatom.py

    r4663 r4783  
    1010from ndgUtils.lib.utilities import getTripleData 
    1111import ndgutilstests.testconstants as tc 
     12from ndgUtils.models import AtomState 
    1213 
    1314class testatom(unittest.TestCase): 
     
    198199        self.atom.addUniqueLinks(data, links) 
    199200        self.assertEqual(2, len(data)) 
     201 
     202    def testIsPublished(self): 
     203        self.assertFalse(self.atom.isPublished()) 
     204        self.atom.state = AtomState.PUBLISHED_STATE 
     205        self.assertTrue(self.atom.isPublished()) 
     206         
     207    def testStateKeyword(self): 
     208        self.atom = Atom(VTD.GRANULE_TERM, vocabTermData = self.VTD,  
     209                         state = AtomState.OLD_STATE) 
     210        self.assertEqual(AtomState.OLD_STATE, self.atom.state) 
     211        self.assertFalse(self.atom.isPublished()) 
     212         
    200213         
    201214 
  • exist/trunk/python/ndgutilstests/testconstants.py

    r4696 r4783  
    1313__revision__ = '$Id: $' 
    1414 
     15from ndgUtils.eXistConnector import eXistConnector as ec 
    1516from ndgUtils.models.vocabtermdata import VocabTermData as VTD 
    1617import os 
  • exist/trunk/python/ndgutilstests/testutils.py

    r4663 r4783  
    2929        atom = self.createAtom(content) 
    3030        return self.dbc.createAtomInExist(atom) 
     31     
     32    def deleteAtomInExist(self, path): 
     33        self.dbc.deleteEXistFile(path) 
Note: See TracChangeset for help on using the changeset viewer.