Changeset 8547 for mauRepo/MolesManager


Ignore:
Timestamp:
30/08/12 10:31:49 (7 years ago)
Author:
mnagni
Message:

Complete - # 22528: Migration of FAtCat Open Search link for HPFeld
 http://team.ceda.ac.uk/trac/ceda/ticket/22528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/tests/cedamoles/mo/responsiblePartyInfo.py

    r8522 r8547  
    6363    def testCreationAndDelete(self): 
    6464        ''' 
    65         Creates and delete a MO_REsponsiblePartyInfo containing two parties. 
     65        Creates and delete a MO_ResponsiblePartyInfo containing two parties. 
    6666         
    6767        **Tests** 
     
    6969         1. Deletes `RP` 
    7070         1. When `RP` is deleted the parties referred from `RP.party` ARE NOT deleted from the database  
    71         '''    
     71        ''' 
     72        if not hasattr(CedaMolesTest.epbRepo, 'moles3EPB'): 
     73            self.fail("The db connection is not no properly initialized") 
     74             
     75        moles3EPB = getattr(CedaMolesTest.epbRepo, 'moles3EPB')     
    7276        rp = _createResponsibleParty() 
    73         self.epbRepo.moles3EPB.persistInstance(rp) 
     77        moles3EPB.persistInstance(rp) 
    7478        self.assertTrue(len(rp.party) == 2, "Error") 
    7579        self.assertEqual(rp.role, getCLValue(MM_RoleValue.cl_publisher), "Error") 
     
    8387        #----------------------------- 
    8488        rpid = getattr(rp, 'id') 
    85         self.epbRepo.moles3EPB.deleteInstance(rp, commit = True) 
    86         self.assertEqual(self.epbRepo.moles3EPB.search(MO_ResponsiblePartyInfo, rpid), None, "Error") 
     89        moles3EPB.deleteInstance(rp, commit = True) 
     90        self.assertEqual(moles3EPB.search(MO_ResponsiblePartyInfo, rpid), None, "Error") 
    8791        #----------------------------- 
    8892         
    8993        # Verifies that the underlying parties has been deleted 
    9094        #---------------------------------------------------- 
    91         res = self.epbRepo.moles3EPB.search(MO_Organisation, partyIds[0]) 
     95        res = moles3EPB.search(MO_Organisation, partyIds[0]) 
    9296        self.assertTrue(res.id in partyIds, "Error") 
    93         res = self.epbRepo.moles3EPB.search(MO_Organisation, partyIds[1]) 
     97        res = moles3EPB.search(MO_Organisation, partyIds[1]) 
    9498        self.assertTrue(res.id in partyIds, "Error") 
    9599        #---------------------------------------------------- 
     
    111115             
    112116        ''' 
     117        if not hasattr(CedaMolesTest.epbRepo, 'moles3EPB'): 
     118            self.fail("The db connection is not no properly initialized") 
     119             
     120        moles3EPB = getattr(CedaMolesTest.epbRepo, 'moles3EPB') 
     121         
    113122        rp = _createResponsibleParty()                
    114123        pi = createAssociateIndexes(rp) 
     
    117126        pi.id = None 
    118127        try:         
    119             self.epbRepo.moles3EPB.persistInstance(pi) 
     128            moles3EPB.persistInstance(pi) 
    120129            self.fail("PartyIndexes.id cannot be None - PrimaryKey Error") 
    121130        except: 
    122             self.epbRepo.moles3EPB.rollback() 
     131            moles3EPB.rollback() 
    123132        #----------------------------------- 
    124133         
     
    126135        pi.id = 100 
    127136        try: 
    128             self.epbRepo.moles3EPB.persistInstance(pi) 
     137            moles3EPB.persistInstance(pi) 
    129138            self.fail("PartyIndexes.id has not associated MO_REsponsiblePartyInfo - ForeignKey Error") 
    130139        except: 
    131             self.epbRepo.moles3EPB.rollback() 
     140            moles3EPB.rollback() 
    132141        #----------------------------------- 
    133142         
    134143        #------------ Test 3 --------------- 
    135         self.epbRepo.moles3EPB.persistInstance(rp) 
     144        moles3EPB.persistInstance(rp) 
    136145        pi.id = getattr(rp, 'id') 
    137146        try: 
    138             self.epbRepo.moles3EPB.persistInstance(pi) 
     147            moles3EPB.persistInstance(pi) 
    139148            self.fail("PartyIndexes.id has not associated MO_REsponsiblePartyInfo - ForeignKey Error") 
    140149        except Exception as e: 
    141             self.epbRepo.moles3EPB.rollback() 
     150            moles3EPB.rollback() 
    142151        #----------------------------------- 
    143152         
    144153        #------------ Test 4 --------------- 
    145154        resId = getattr(rp, 'id') 
    146         self.epbRepo.moles3EPB.expunge(rp) 
    147         res = self.epbRepo.moles3EPB.search(MO_ResponsiblePartyInfo, resId) 
     155        moles3EPB.expunge(rp) 
     156        res = moles3EPB.search(MO_ResponsiblePartyInfo, resId) 
    148157        for party in res.party: 
    149158            self.assertTrue(party.party_order > -1, "MO_Party.party_order is not assigned - Error") 
     
    151160         
    152161        #------------ Test 5 --------------- 
    153         self.epbRepo.moles3EPB.deleteInstance(res, commit = True) 
    154         pi = self.epbRepo.moles3EPB.search(PartyIndexes, resId) 
     162        moles3EPB.deleteInstance(res, commit = True) 
     163        pi = moles3EPB.search(PartyIndexes, resId) 
    155164        self.assertTrue(pi is None, "PartyIndexes is not deleted after MO_ResponsiblePartyInfo is deleted - Error") 
    156165        #----------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.