Ignore:
Timestamp:
31/07/12 15:35:45 (8 years ago)
Author:
mnagni
Message:

Implemented adapters for TM_Instant, TM_Period and partially for CEDA_Observation

Added a Sphinx documentation folder

Location:
mauRepo/MolesManager/trunk/tests/moles2gui/mo
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/tests/moles2gui/mo/party.py

    r8476 r8477  
    3232''' 
    3333import unittest 
    34 from moles2gui.creationFactory import assembleMO_Organization, assembleMO_Individual,\ 
    35     assembleMO_ResponsiblePartyInfo 
     34from moles2gui.creationFactory import assembleMO_Organization, assembleMO_Individual 
    3635from json import loads, dumps 
    3736from MolesManager.views.moles2gui import encodeCedaMoles2Json,\ 
    38     decodeJson2CedaMoles, dictByID, getData, _encodeCedaMoles2Adapter 
    39 from MolesManager.codelist import getCLValue, MM_RoleValue 
     37    decodeJson2CedaMoles, getData 
    4038 
    4139 
     
    5048 
    5149    def tearDown(self): 
    52         pass 
     50        pass             
    5351 
    54     def testGUIs(self): 
    55         self.validateMO_Individual1() 
    56         self.validateMO_Individual2()   
    57         self.validateMO_Organization1()    
    58         self.validateMO_Organization2()         
    59         self.validatResponsibleParty1() 
    60         self.validatResponsibleParty2() 
    61         self.validatResponsibleParty3()         
    62  
    63     def validateMO_Individual1(self):        
     52    def testValidateMO_Individual1(self):        
    6453        party = assembleMO_Individual() 
    65         jparty = encodeCedaMoles2Json(party) 
     54        json = encodeCedaMoles2Json(party) 
    6655        #----------------------- test ------------------------ 
    67         decJson = loads(jparty) 
     56        decJson = loads(json) 
    6857        self.assertEqual(decJson['name'], party.name, "Error") 
    6958        #----------------------------------------------------- 
    7059         
    7160        #----------------------- test ------------------------ 
    72         nparty = decodeJson2CedaMoles(json = jparty, cedaMoleObj = party) 
     61        nparty = decodeJson2CedaMoles(json = json, cedaMoleObj = party) 
    7362        self.assertEqual(nparty.name, party.name, "decodeJson2CedaMoles Error") 
    7463        #----------------------------------------------------- 
    7564 
    76     def validateMO_Individual2(self):        
     65    def testValidateMO_Individual2(self):        
    7766        party = assembleMO_Individual() 
    7867        jparty = encodeCedaMoles2Json(party) 
     
    8675        #--------------------------------------------------------- 
    8776 
    88     def validateMO_Organization1(self):        
     77    def testValidateMO_Organization1(self):        
    8978        party = assembleMO_Organization() 
    9079        jparty = encodeCedaMoles2Json(party) 
     
    9988        #----------------------------------------------------- 
    10089 
    101     def validateMO_Organization2(self):        
     90    def testValidateMO_Organization2(self):        
    10291        party = assembleMO_Organization() 
    10392        jparty = encodeCedaMoles2Json(party) 
     
    11099        self.assertEqual(decJson['helpEmail'], getData(nparty, 'contactInfo[0].address.electronicMailAddress'), "decodeJson2CedaMoles Error") 
    111100        #----------------------------------------------------- 
    112  
    113     def validatResponsibleParty1(self): 
    114         rp = assembleMO_ResponsiblePartyInfo() 
    115         jrp = encodeCedaMoles2Json(rp) 
    116          
    117         #----------------------- test ------------------------ 
    118         ordParty = dictByID(rp.party) 
    119         decJson = loads(jrp) 
    120         for party in decJson['party']: 
    121             self.assertEqual(party['name'], ordParty[party['id']].name, "Error") 
    122         #----------------------------------------------------- 
    123         decodeJson2CedaMoles(jrp, cedaMoleObj = rp) 
    124  
    125     def validatResponsibleParty2(self): 
    126         # Creates a MO_ResponsibleParty and modifies 
    127         newrp = assembleMO_ResponsiblePartyInfo()  
    128         if len(newrp.party[0].contactInfo) > 0: 
    129             newrp.party[0].contactInfo[0].address.electronicMailAddress.append('mau@mau.net') 
    130         else: 
    131             newrp.party[1].contactInfo[0].address.electronicMailAddress.append('mau@mau.net') 
    132              
    133         # Converts to json to simulate a modified incoming json from the page 
    134         jrp = encodeCedaMoles2Json(newrp) 
    135          
    136         # Creates a MO_Responsible party to simulate the original responsibleParty 
    137         oldrp = assembleMO_ResponsiblePartyInfo() 
    138                  
    139         #----------------------- test ------------------------ 
    140         # Updates the "original" using the modified json  
    141         decodeJson2CedaMoles(jrp, cedaMoleObj = oldrp) 
    142         # Now the oldrp should look equal to newrp 
    143         for newparty in newrp.party: 
    144             for oldparty in  oldrp.party: 
    145                 if oldparty.id == newparty.id: 
    146                     self.assertTrue(len(oldparty.contactInfo) ==  len(newparty.contactInfo), "Error") 
    147                     if len(oldparty.contactInfo) == 0: 
    148                         continue 
    149                     for email in oldparty.contactInfo[0].address.electronicMailAddress: 
    150                         self.assertTrue(email in newparty.contactInfo[0].address.electronicMailAddress, "Error") 
    151         #----------------------------------------------------- 
    152  
    153     def validatResponsibleParty3(self): 
    154         rp = assembleMO_ResponsiblePartyInfo(role = getCLValue(MM_RoleValue.cl_pointofcontact)) 
    155         adapter = _encodeCedaMoles2Adapter(rp) 
    156          
    157         #----------------------- test ------------------------ 
    158         for party in adapter.party: 
    159             self.assertTrue(len(party.helpString) > 0, "Error") 
    160         #----------------------------------------------------- 
    161          
    162         jrp = encodeCedaMoles2Json(rp) 
    163         decodeJson2CedaMoles(jrp, cedaMoleObj = rp) 
    164  
    165 if __name__ == "__main__": 
    166     #import sys;sys.argv = ['', 'Test.testName'] 
    167     unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.