Changeset 1249

Show
Ignore:
Timestamp:
04/07/08 22:03:38 (8 months ago)
Author:
sgillies
Message:

Bring every tests except the GeoRSS and KML one into the new suite

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PleiadesEntity/trunk/Extensions/loader.py

    r1244 r1249  
    157157    portalcontext.""" 
    158158    
    159     wftool = getToolByName(portalcontext, 'portal_workflow') 
     159    #wftool = getToolByName(portalcontext, 'portal_workflow') 
    160160 
    161161    for tp in  xmlcontext.findall("{%s}timePeriod" % ADLGAZ): 
     
    190190            raise EntityLoadError, "There is already a TemporalAttestation with id=%s in portal context = %s" % (id, portalcontext.Title()) 
    191191 
    192         wftool.doActionFor(getattr(portalcontext, id), "publish") 
     192        #wftool.doActionFor(getattr(portalcontext, id), "publish") 
    193193 
    194194def getalltext(elem): 
     
    198198    return text.strip() 
    199199 
    200 def parse_secondary_references(xmlcontext, portalcontext, ptool, wftool): 
     200def parse_secondary_references(xmlcontext, portalcontext, ptool, wftool=None): 
    201201    srs =  xmlcontext.find("{%s}secondaryReferences" % AWMC) 
    202202    if srs: 
     
    223223                    #raise EntityLoadError, "There is already a SecondaryReference with id=%s in portal context" % id 
    224224                 
    225                 wftool.doActionFor(getattr(portalcontext, id), "publish") 
     225                #wftool.doActionFor(getattr(portalcontext, id), "publish") 
    226226 
    227227import sys 
     
    249249        raise Exception, "Number of allowable name duplicates exceeded" 
    250250 
    251 def parse_names(xmlcontext, portalcontext, ptool, wftool): 
     251def parse_names(xmlcontext, portalcontext, ptool, wftool=None): 
    252252    root = xmlcontext 
    253253    names = portalcontext 
     
    354354            name = getattr(names.duplicates, nid) 
    355355 
    356         wftool.doActionFor(name, "publish") 
     356        #wftool.doActionFor(name, "publish") 
    357357          
    358358        nids.append(nid) 
     
    363363         
    364364        # SecondaryReferences associated with the name 
    365         parse_secondary_references(e, name, ptool, wftool) 
     365        parse_secondary_references(e, name, ptool) #, wftool) 
    366366        #name.reindexObject() 
    367367         
    368368    return (nids, association_certainties) 
    369369 
    370 def parse_locations(xmlcontext, portalcontext, ptool, wftool): 
     370def parse_locations(xmlcontext, portalcontext, ptool, wftool=None): 
    371371    root = xmlcontext 
    372372    lids = [] 
     
    386386                    ) 
    387387         
    388         wftool.doActionFor(getattr(portalcontext, lid), "publish") 
     388        #wftool.doActionFor(getattr(portalcontext, lid), "publish") 
    389389        lids.append(lid) 
    390390         
     
    401401 
    402402    ptool = getToolByName(site, 'plone_utils') 
    403     wftool = getToolByName(site, 'portal_workflow') 
     403    #wftool = getToolByName(site, 'portal_workflow') 
    404404 
    405405    places = site.places 
     
    415415             
    416416        # Names 
    417         nids, association_certainties = parse_names(root, names, ptool, wftool) 
     417        nids, association_certainties = parse_names(root, names, ptool) #, wftool) 
    418418 
    419419        # Locations 
    420         lids = parse_locations(root, locations, ptool, wftool) 
     420        lids = parse_locations(root, locations, ptool) #, wftool) 
    421421     
    422422        # Place 
     
    469469                    ) 
    470470        p = getattr(places, pid) 
    471         wftool.doActionFor(p, "publish") 
     471        #wftool.doActionFor(p, "publish") 
    472472        #p.reindexObject() 
    473473     
     
    483483                a = getattr(p, aid) 
    484484                a.addReference(getattr(locations, lid), 'hasLocation') 
    485                 wftool.doActionFor(a, "publish") 
     485                #wftool.doActionFor(a, "publish") 
    486486             
    487487                # Secondary references for the place 
    488                 parse_secondary_references(root, a, ptool, wftool) 
     488                parse_secondary_references(root, a, ptool) #, wftool) 
    489489                #a.reindexObject() 
    490490             
     
    502502                    a.addReference(getattr(locations, lid), 'hasLocation') 
    503503                    a.addReference(getattr(names, nid), 'hasName') 
    504                     wftool.doActionFor(a, "publish") 
     504                    #wftool.doActionFor(a, "publish") 
    505505             
    506506                    # Secondary references for the place 
    507                     parse_secondary_references(root, a, ptool, wftool) 
     507                    parse_secondary_references(root, a, ptool) #, wftool) 
    508508                    #a.reindexObject() 
    509509     
     
    518518                a = getattr(p, aid) 
    519519                a.addReference(getattr(names, nid), 'hasName') 
    520                 wftool.doActionFor(a, "publish") 
     520                #wftool.doActionFor(a, "publish") 
    521521                # Secondary references for the place 
    522                 parse_secondary_references(root, a, ptool, wftool) 
     522                parse_secondary_references(root, a, ptool) #, wftool) 
    523523                #a.reindexObject() 
    524524 
  • PleiadesEntity/trunk/tests/BatchLoad.txt

    r1247 r1249  
    11Batch Loading of Entities 
    22========================= 
    3  
    4 Check catalogs 
    5 -------------- 
    6  
    7   >>> uc = self.portal.uid_catalog 
    8   >>> rc = self.portal.reference_catalog 
    93 
    104Setup 
     
    126 
    137  >>> self.setRoles(('Manager',)) 
    14  
    15   Enable types 
    16  
    17   >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    18   >>> lpf_allow = lpf.global_allow 
    19   >>> lpf.global_allow = True 
    20  
    21   >>> n = self.portal.portal_types['Name'] 
    22   >>> n_allow = n.global_allow 
    23   >>> n.global_allow = True 
    24  
    25   Alias the test folder 
    26  
    278  >>> folder = self.folder 
    28  
    29   Containers 
    30  
    31   >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    32   >>> _ = folder.names.invokeFactory('Large Plone Folder', id='duplicates') 
    33   >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    34   >>> _ = folder.invokeFactory('PlaceContainer', id='places') 
    359 
    3610Load entities 
  • PleiadesEntity/trunk/tests/Entities.txt

    r1245 r1249  
    66----- 
    77 
    8     Check catalogs 
    9  
    10     >>> uc = self.portal.uid_catalog 
    11     >>> rc = self.portal.reference_catalog 
    12  
    13     Enable types 
    14  
    15     >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    16     >>> lpf_allow = lpf.global_allow 
    17     >>> lpf.global_allow = True 
    18  
    19     >>> n = self.portal.portal_types['Name'] 
    20     >>> n_allow = n.global_allow 
    21     >>> n.global_allow = True 
    22  
    238    Alias the test folder 
    249 
    2510    >>> folder = self.folder 
    26  
    27     Containers 
    28  
    29     >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    30     >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    31     >>> _ = folder.invokeFactory('PlaceContainer', id='places') 
    3211    >>> names = folder.names 
    3312    >>> locations = folder.locations 
  • PleiadesEntity/trunk/tests/LoadEntity.txt

    r1246 r1249  
    22========================= 
    33 
    4 Check catalogs 
    5 -------------- 
    6  
    7     >>> uc = self.portal.uid_catalog 
    8     >>> rc = self.portal.reference_catalog 
    9  
    104Setup 
    115----- 
     
    137    >>> import transaction 
    148    >>> self.setRoles(('Manager',)) 
    15  
    16     Enable types 
    17  
    18     >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    19     >>> lpf_allow = lpf.global_allow 
    20     >>> lpf.global_allow = True 
    21  
    22     >>> n = self.portal.portal_types['Name'] 
    23     >>> n_allow = n.global_allow 
    24     >>> n.global_allow = True 
    25  
    26     Alias the test folder 
    27  
    289    >>> folder = self.folder 
    29  
    30     Containers 
    31  
    32     >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    33     >>> _ = folder.names.invokeFactory('Large Plone Folder', id='duplicates') 
    34     >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    35     >>> _ = folder.invokeFactory('PlaceContainer', id='places') 
    36  
    37     >>> transaction.commit() 
    3810 
    3911Load one entity 
  • PleiadesEntity/trunk/tests/LocationViews.txt

    r1248 r1249  
    66----- 
    77 
    8     >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    98    >>> lid = folder.locations.invokeFactory('Location') 
    109    >>> x = getattr(folder.locations, lid) 
  • PleiadesEntity/trunk/tests/NameViews.txt

    r1248 r1249  
    66----- 
    77 
    8     >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    9     >>> lpf_allow = lpf.global_allow 
    10     >>> lpf.global_allow = True 
    11  
    12     >>> n = self.portal.portal_types['Name'] 
    13     >>> n_allow = n.global_allow 
    14     >>> n.global_allow = True 
    15  
    168    >>> folder = self.folder 
    17  
    18     >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    19     >>> _ = folder.names.invokeFactory('Name', id='neverpolis') 
    20     >>> n = getattr(folder.names, 'neverpolis') 
     9    >>> name = folder.names.invokeFactory('Name', id='neverpolis') 
     10    >>> n = getattr(folder.names, name) 
    2111 
    2212 
  • PleiadesEntity/trunk/tests/Names.txt

    r740 r1249  
    55----- 
    66 
    7     Enable types 
    8  
    9     >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    10     >>> lpf_allow = lpf.global_allow 
    11     >>> lpf.global_allow = True 
    12  
    13     >>> n = self.portal.portal_types['Name'] 
    14     >>> n_allow = n.global_allow 
    15     >>> n.global_allow = True 
    16  
    17     Alias the test folder 
    18  
    197    >>> folder = self.folder 
    208 
    21     Containers 
    22  
    23     >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    24     >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    25     >>> _ = folder.invokeFactory('PlaceContainer', id='places') 
    26     
    279Load one fiendish entity 
    2810------------------------ 
    2911 
     12    >>> TEST_DATA = self.test_params.TEST_DATA 
     13    >>> from Products.PleiadesEntity.Extensions.loader import load_place 
    3014    >>> r = load_place(folder, "%s/nametwister.xml" % TEST_DATA) 
    3115    Traceback (most recent call last): 
  • PleiadesEntity/trunk/tests/TemporalAttestations.txt

    r696 r1249  
    11Boundary conditions for TemporalAttestations 
    22========================= 
    3  
    4 Check catalogs 
    5 -------------- 
    6  
    7     >>> uc = self.portal.uid_catalog 
    8     >>> rc = self.portal.reference_catalog 
    93 
    104Setup 
    115----- 
    126 
    13     Enable types 
    14  
    15     >>> lpf = self.portal.portal_types['Large Plone Folder'] 
    16     >>> lpf_allow = lpf.global_allow 
    17     >>> lpf.global_allow = True 
    18  
    19     >>> n = self.portal.portal_types['Name'] 
    20     >>> n_allow = n.global_allow 
    21     >>> n.global_allow = True 
    22  
    23     Alias the test folder 
    24  
    257    >>> folder = self.folder 
    26  
    27     Containers 
    28  
    29     >>> _ = folder.invokeFactory('Large Plone Folder', id='names') 
    30     >>> _ = folder.invokeFactory('LocationContainer', id='locations') 
    31     >>> _ = folder.invokeFactory('PlaceContainer', id='places') 
    32     >>> folder.places._v_nextid = BA_ID_MAX 
    338 
    349 
     
    3611------------- 
    3712 
     13    >>> from Products.PleiadesEntity.Extensions.loader import format_listofstrings 
    3814    >>> format_listofstrings([]) 
    3915    u'' 
     
    4521    u'x, y and z' 
    4622     
     23    >>> from Products.PleiadesEntity.Extensions.xmlutil import purifyText 
    4724    >>> purifyText(u'aaa') == u'aaa' 
    4825    True 
     
    5532--------------- 
    5633 
     34    >>> TEST_DATA = self.test_params.TEST_DATA 
     35    >>> from Products.PleiadesEntity.Extensions.loader import load_place 
    5736    >>> r = load_place(folder, "%s/timetwister.xml" % TEST_DATA) 
    58     >>> int(r['place_id']) >= BA_ID_MAX 
    59     True 
    6037    >>> r['name_ids'] 
    6138    ['time-twister', 'tome-twirling'] 
     
    6744    >>> len(tps) 
    6845    2 
    69     >>> tps[0].Title 
     46    >>> tps0 = tps[0].getObject() 
     47    >>> tps0.Title() 
    7048    'Attested: Classical (550 - 330 BC)' 
    71     >>> tps[0].getId 
     49    >>> tps0.getId() 
    7250    'classical' 
    73     >>> tps[0].getAttestationConfidence 
     51    >>> tps0.getAttestationConfidence() 
    7452    'confident' 
    7553     
    76     >>> tps[1].Title 
     54    >>> tps1 = tps[1].getObject() 
     55    >>> tps1.Title() 
    7756    'Attested: Hellenistic/Republican (330 - 30 BC)?' 
    78     >>> tps[1].getId 
     57    >>> tps1.getId() 
    7958    'hellenistic-republican' 
    80     >>> tps[1].getAttestationConfidence 
     59    >>> tps1.getAttestationConfidence() 
    8160    'less-confident' 
    8261     
     
    8564    >>> len(tps) 
    8665    2 
    87     >>> tps[0].Title 
     66    >>> tps0 = tps[0].getObject() 
     67    >>> tps0.Title() 
    8868    'Attested: Roman (30 BC - AD 300) - inferred' 
    89     >>> tps[0].getId 
     69    >>> tps0.getId() 
    9070    'roman' 
    91     >>> tps[0].getAttestationConfidence 
     71    >>> tps0.getAttestationConfidence() 
    9272    'confident-inferred' 
    93      
    94     >>> tps[1].Title 
     73    
     74    >>> tps1 = tps[1].getObject() 
     75    >>> tps1.Title() 
    9576    'Attested: Late Antique (AD 300 - 625)? - inferred' 
    96     >>> tps[1].getId 
     77    >>> tps1.getId() 
    9778    'late-antique' 
    98     >>> tps[1].getAttestationConfidence 
     79    >>> tps1.getAttestationConfidence() 
    9980    'less-confident-inferred' 
    10081 
     
    10687    >>> len(tps) 
    10788    5 
    108     >>> tps[0].Title 
     89    >>> tps0 = tps[0].getObject() 
     90    >>> tps0.Title() 
    10991    'Attested: Archaic (pre-550 BC)' 
    110     >>> tps[0].getId 
     92    >>> tps0.getId() 
    11193    'archaic' 
    112     >>> tps[0].getAttestationConfidence 
     94    >>> tps0.getAttestationConfidence() 
    11395    'confident' 
    114      
    115     >>> tps[1].Title 
     96    
     97    >>> tps1 = tps[1].getObject() 
     98    >>> tps1.Title() 
    11699    'Attested: Classical (550 - 330 BC)' 
    117     >>> tps[1].getId 
     100    >>> tps1.getId() 
    118101    'classical' 
    119     >>> tps[1].getAttestationConfidence 
     102    >>> tps1.getAttestationConfidence() 
    120103    'confident' 
    121      
    122     >>> tps[2].Title 
     104    
     105    >>> tps2 = tps[2].getObject() 
     106    >>> tps2.Title() 
    123107    'Attested: Hellenistic/Republican (330 - 30 BC)?' 
    124     >>> tps[2].getId 
     108    >>> tps2.getId() 
    125109    'hellenistic-republican' 
    126     >>> tps[2].getAttestationConfidence 
     110    >>> tps2.getAttestationConfidence() 
     111    'less-confident' 
     112    
     113    >>> tps3 = tps[3].getObject() 
     114    >>> tps3.Title() 
     115    'Attested: Roman (30 BC - AD 300)' 
     116    >>> tps3.getId() 
     117    'roman' 
     118    >>> tps3.getAttestationConfidence() 
     119    'confident' 
     120    
     121    >>> tps4 = tps[4].getObject() 
     122    >>> tps4.Title() 
     123    'Attested: Late Antique (AD 300 - 625)?' 
     124    >>> tps4.getId() 
     125    'late-antique' 
     126    >>> tps4.getAttestationConfidence() 
    127127    'less-confident' 
    128128     
    129     >>> tps[3].Title 
    130     'Attested: Roman (30 BC - AD 300)' 
    131     >>> tps[3].getId 
    132     'roman' 
    133     >>> tps[3].getAttestationConfidence 
    134     'confident' 
    135      
    136     >>> tps[4].Title 
    137     'Attested: Late Antique (AD 300 - 625)?' 
    138     >>> tps[4].getId 
    139     'late-antique' 
    140     >>> tps[4].getAttestationConfidence 
    141     'less-confident' 
    142      
  • PleiadesEntity/trunk/tests/Vocabularies.txt

    r706 r1249  
    1414    'Types of Places Distinguished in AWMC Publications' 
    1515    >>> len([obj for obj in v.contentValues() if obj.meta_type == "VdexTerm"]) 
    16     51 
     16    52 
    1717 
    1818Test ancient name types vocabulary 
     
    2323    'Types of Historical Names Distinguished in AWMC Publications' 
    2424    >>> len([obj for obj in v.contentValues() if obj.meta_type == "VdexTerm"]) 
    25     3 
     25    4 
    2626 
    2727Test ancient name languages vocabulary 
  • PleiadesEntity/trunk/tests/test_docfiles.py

    r1248 r1249  
    66from Testing import ZopeTestCase as ztc 
    77from Products.PloneTestCase import PloneTestCase as ptc 
    8 from Products.PloneTestCase.layer import onsetup, PloneSite 
     8from Products.PloneTestCase.layer import onsetup, PloneSite, ZCMLLayer 
    99import _testing 
    1010 
     
    1414ptc.setupPloneSite(products=['Archetypes', 'ATVocabularyManager', 'Geographer', 'PleiadesEntity']) 
    1515 
    16 optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE 
     16optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE # | doctest.REPORT_ONLY_FIRST_FAILURE 
    1717 
    1818class PleiadesEntityTestCase(ptc.PloneTestCase): 
    1919 
     20    layer = PloneSite 
     21 
    2022    def afterSetUp(self): 
    2123        self.test_params = _testing 
     24         
     25        lpf = self.portal.portal_types['Large Plone Folder'] 
     26        lpf_allow = lpf.global_allow 
     27        lpf.global_allow = True 
    2228 
     29        n = self.portal.portal_types['Name'] 
     30        n_allow = n.global_allow 
     31        n.global_allow = True 
     32 
     33        # Currently this stuff isn't being torn down between doctests. Why not? 
     34        try: 
     35            self.folder.invokeFactory('Large Plone Folder', id='names') 
     36            self.folder['names'].invokeFactory('Large Plone Folder',id='duplicates') 
     37            self.folder.invokeFactory('LocationContainer', id='locations') 
     38            self.folder.invokeFactory('PlaceContainer', id='places') 
     39        except: 
     40            pass 
     41 
     42integration_tests = [ 
     43    'Entities.txt', 
     44    'Names.txt', 
     45    'TemporalAttestations.txt', 
     46    'Vocabularies.txt', 
     47    'WSTransliteration.txt', 
     48    'WSValidation.txt', 
     49    'LoadEntity.txt', 
     50    'BatchLoad.txt' 
     51    ] 
     52 
     53functional_tests = [ 
     54    'LocationViews.txt', 
     55    'NameViews.txt' 
     56    ] 
     57 
     58def make_integration_suite(name): 
     59    return ztc.ZopeDocFileSuite( 
     60                name, 
     61                package='Products.PleiadesEntity.tests', 
     62                test_class=PleiadesEntityTestCase, 
     63                optionflags=optionflags, 
     64                ) 
     65 
     66def make_functional_suite(name): 
     67    return ztc.FunctionalDocFileSuite( 
     68                name, 
     69                package='Products.PleiadesEntity.tests', 
     70                test_class=PleiadesEntityTestCase, 
     71                optionflags=optionflags, 
     72                ) 
    2373 
    2474def test_suite(): 
    25     return unittest.TestSuite([ 
    26         ztc.ZopeDocFileSuite( 
    27             'Entities.txt', 
    28             package='Products.PleiadesEntity.tests', 
    29             test_class=PleiadesEntityTestCase, 
    30             optionflags=optionflags, 
    31             ), 
    32         ztc.ZopeDocFileSuite( 
    33             'LoadEntity.txt', 
    34             package='Products.PleiadesEntity.tests', 
    35             test_class=PleiadesEntityTestCase, 
    36             optionflags=optionflags, 
    37             ), 
    38         ztc.ZopeDocFileSuite( 
    39             'BatchLoad.txt', 
    40             package='Products.PleiadesEntity.tests', 
    41             test_class=PleiadesEntityTestCase, 
    42             optionflags=optionflags, 
    43             ), 
    44         ztc.FunctionalDocFileSuite( 
    45             'LocationViews.txt', 
    46             package='Products.PleiadesEntity.tests', 
    47             test_class=PleiadesEntityTestCase, 
    48             optionflags=optionflags, 
    49             ), 
    50         ztc.FunctionalDocFileSuite( 
    51             'NameViews.txt', 
    52             package='Products.PleiadesEntity.tests', 
    53             test_class=PleiadesEntityTestCase, 
    54             optionflags=optionflags, 
    55             ), 
    56         ]) 
     75    return unittest.TestSuite( 
     76        [make_integration_suite(n) for n in integration_tests]  
     77      + [make_functional_suite(n) for n in functional_tests] 
     78      ) 
    5779 
    5880if __name__ == '__main__': 
    5981    unittest.main(defaultTest='test_suite') 
     82