Changeset 1249
- Timestamp:
- 04/07/08 22:03:38 (8 months ago)
- Files:
-
- PleiadesEntity/trunk/Extensions/loader.py (modified) (14 diffs)
- PleiadesEntity/trunk/tests/BatchLoad.txt (modified) (2 diffs)
- PleiadesEntity/trunk/tests/Entities.txt (modified) (1 diff)
- PleiadesEntity/trunk/tests/LoadEntity.txt (modified) (2 diffs)
- PleiadesEntity/trunk/tests/LocationViews.txt (modified) (1 diff)
- PleiadesEntity/trunk/tests/NameViews.txt (modified) (1 diff)
- PleiadesEntity/trunk/tests/Names.txt (modified) (1 diff)
- PleiadesEntity/trunk/tests/TemporalAttestations.txt (modified) (7 diffs)
- PleiadesEntity/trunk/tests/Vocabularies.txt (modified) (2 diffs)
- PleiadesEntity/trunk/tests/test_docfiles.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesEntity/trunk/Extensions/loader.py
r1244 r1249 157 157 portalcontext.""" 158 158 159 wftool = getToolByName(portalcontext, 'portal_workflow')159 #wftool = getToolByName(portalcontext, 'portal_workflow') 160 160 161 161 for tp in xmlcontext.findall("{%s}timePeriod" % ADLGAZ): … … 190 190 raise EntityLoadError, "There is already a TemporalAttestation with id=%s in portal context = %s" % (id, portalcontext.Title()) 191 191 192 wftool.doActionFor(getattr(portalcontext, id), "publish")192 #wftool.doActionFor(getattr(portalcontext, id), "publish") 193 193 194 194 def getalltext(elem): … … 198 198 return text.strip() 199 199 200 def parse_secondary_references(xmlcontext, portalcontext, ptool, wftool ):200 def parse_secondary_references(xmlcontext, portalcontext, ptool, wftool=None): 201 201 srs = xmlcontext.find("{%s}secondaryReferences" % AWMC) 202 202 if srs: … … 223 223 #raise EntityLoadError, "There is already a SecondaryReference with id=%s in portal context" % id 224 224 225 wftool.doActionFor(getattr(portalcontext, id), "publish")225 #wftool.doActionFor(getattr(portalcontext, id), "publish") 226 226 227 227 import sys … … 249 249 raise Exception, "Number of allowable name duplicates exceeded" 250 250 251 def parse_names(xmlcontext, portalcontext, ptool, wftool ):251 def parse_names(xmlcontext, portalcontext, ptool, wftool=None): 252 252 root = xmlcontext 253 253 names = portalcontext … … 354 354 name = getattr(names.duplicates, nid) 355 355 356 wftool.doActionFor(name, "publish")356 #wftool.doActionFor(name, "publish") 357 357 358 358 nids.append(nid) … … 363 363 364 364 # SecondaryReferences associated with the name 365 parse_secondary_references(e, name, ptool , wftool)365 parse_secondary_references(e, name, ptool) #, wftool) 366 366 #name.reindexObject() 367 367 368 368 return (nids, association_certainties) 369 369 370 def parse_locations(xmlcontext, portalcontext, ptool, wftool ):370 def parse_locations(xmlcontext, portalcontext, ptool, wftool=None): 371 371 root = xmlcontext 372 372 lids = [] … … 386 386 ) 387 387 388 wftool.doActionFor(getattr(portalcontext, lid), "publish")388 #wftool.doActionFor(getattr(portalcontext, lid), "publish") 389 389 lids.append(lid) 390 390 … … 401 401 402 402 ptool = getToolByName(site, 'plone_utils') 403 wftool = getToolByName(site, 'portal_workflow')403 #wftool = getToolByName(site, 'portal_workflow') 404 404 405 405 places = site.places … … 415 415 416 416 # Names 417 nids, association_certainties = parse_names(root, names, ptool , wftool)417 nids, association_certainties = parse_names(root, names, ptool) #, wftool) 418 418 419 419 # Locations 420 lids = parse_locations(root, locations, ptool , wftool)420 lids = parse_locations(root, locations, ptool) #, wftool) 421 421 422 422 # Place … … 469 469 ) 470 470 p = getattr(places, pid) 471 wftool.doActionFor(p, "publish")471 #wftool.doActionFor(p, "publish") 472 472 #p.reindexObject() 473 473 … … 483 483 a = getattr(p, aid) 484 484 a.addReference(getattr(locations, lid), 'hasLocation') 485 wftool.doActionFor(a, "publish")485 #wftool.doActionFor(a, "publish") 486 486 487 487 # Secondary references for the place 488 parse_secondary_references(root, a, ptool , wftool)488 parse_secondary_references(root, a, ptool) #, wftool) 489 489 #a.reindexObject() 490 490 … … 502 502 a.addReference(getattr(locations, lid), 'hasLocation') 503 503 a.addReference(getattr(names, nid), 'hasName') 504 wftool.doActionFor(a, "publish")504 #wftool.doActionFor(a, "publish") 505 505 506 506 # Secondary references for the place 507 parse_secondary_references(root, a, ptool , wftool)507 parse_secondary_references(root, a, ptool) #, wftool) 508 508 #a.reindexObject() 509 509 … … 518 518 a = getattr(p, aid) 519 519 a.addReference(getattr(names, nid), 'hasName') 520 wftool.doActionFor(a, "publish")520 #wftool.doActionFor(a, "publish") 521 521 # Secondary references for the place 522 parse_secondary_references(root, a, ptool , wftool)522 parse_secondary_references(root, a, ptool) #, wftool) 523 523 #a.reindexObject() 524 524 PleiadesEntity/trunk/tests/BatchLoad.txt
r1247 r1249 1 1 Batch Loading of Entities 2 2 ========================= 3 4 Check catalogs5 --------------6 7 >>> uc = self.portal.uid_catalog8 >>> rc = self.portal.reference_catalog9 3 10 4 Setup … … 12 6 13 7 >>> self.setRoles(('Manager',)) 14 15 Enable types16 17 >>> lpf = self.portal.portal_types['Large Plone Folder']18 >>> lpf_allow = lpf.global_allow19 >>> lpf.global_allow = True20 21 >>> n = self.portal.portal_types['Name']22 >>> n_allow = n.global_allow23 >>> n.global_allow = True24 25 Alias the test folder26 27 8 >>> folder = self.folder 28 29 Containers30 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')35 9 36 10 Load entities PleiadesEntity/trunk/tests/Entities.txt
r1245 r1249 6 6 ----- 7 7 8 Check catalogs9 10 >>> uc = self.portal.uid_catalog11 >>> rc = self.portal.reference_catalog12 13 Enable types14 15 >>> lpf = self.portal.portal_types['Large Plone Folder']16 >>> lpf_allow = lpf.global_allow17 >>> lpf.global_allow = True18 19 >>> n = self.portal.portal_types['Name']20 >>> n_allow = n.global_allow21 >>> n.global_allow = True22 23 8 Alias the test folder 24 9 25 10 >>> folder = self.folder 26 27 Containers28 29 >>> _ = folder.invokeFactory('Large Plone Folder', id='names')30 >>> _ = folder.invokeFactory('LocationContainer', id='locations')31 >>> _ = folder.invokeFactory('PlaceContainer', id='places')32 11 >>> names = folder.names 33 12 >>> locations = folder.locations PleiadesEntity/trunk/tests/LoadEntity.txt
r1246 r1249 2 2 ========================= 3 3 4 Check catalogs5 --------------6 7 >>> uc = self.portal.uid_catalog8 >>> rc = self.portal.reference_catalog9 10 4 Setup 11 5 ----- … … 13 7 >>> import transaction 14 8 >>> self.setRoles(('Manager',)) 15 16 Enable types17 18 >>> lpf = self.portal.portal_types['Large Plone Folder']19 >>> lpf_allow = lpf.global_allow20 >>> lpf.global_allow = True21 22 >>> n = self.portal.portal_types['Name']23 >>> n_allow = n.global_allow24 >>> n.global_allow = True25 26 Alias the test folder27 28 9 >>> folder = self.folder 29 30 Containers31 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()38 10 39 11 Load one entity PleiadesEntity/trunk/tests/LocationViews.txt
r1248 r1249 6 6 ----- 7 7 8 >>> _ = folder.invokeFactory('LocationContainer', id='locations')9 8 >>> lid = folder.locations.invokeFactory('Location') 10 9 >>> x = getattr(folder.locations, lid) PleiadesEntity/trunk/tests/NameViews.txt
r1248 r1249 6 6 ----- 7 7 8 >>> lpf = self.portal.portal_types['Large Plone Folder']9 >>> lpf_allow = lpf.global_allow10 >>> lpf.global_allow = True11 12 >>> n = self.portal.portal_types['Name']13 >>> n_allow = n.global_allow14 >>> n.global_allow = True15 16 8 >>> 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) 21 11 22 12 PleiadesEntity/trunk/tests/Names.txt
r740 r1249 5 5 ----- 6 6 7 Enable types8 9 >>> lpf = self.portal.portal_types['Large Plone Folder']10 >>> lpf_allow = lpf.global_allow11 >>> lpf.global_allow = True12 13 >>> n = self.portal.portal_types['Name']14 >>> n_allow = n.global_allow15 >>> n.global_allow = True16 17 Alias the test folder18 19 7 >>> folder = self.folder 20 8 21 Containers22 23 >>> _ = folder.invokeFactory('Large Plone Folder', id='names')24 >>> _ = folder.invokeFactory('LocationContainer', id='locations')25 >>> _ = folder.invokeFactory('PlaceContainer', id='places')26 27 9 Load one fiendish entity 28 10 ------------------------ 29 11 12 >>> TEST_DATA = self.test_params.TEST_DATA 13 >>> from Products.PleiadesEntity.Extensions.loader import load_place 30 14 >>> r = load_place(folder, "%s/nametwister.xml" % TEST_DATA) 31 15 Traceback (most recent call last): PleiadesEntity/trunk/tests/TemporalAttestations.txt
r696 r1249 1 1 Boundary conditions for TemporalAttestations 2 2 ========================= 3 4 Check catalogs5 --------------6 7 >>> uc = self.portal.uid_catalog8 >>> rc = self.portal.reference_catalog9 3 10 4 Setup 11 5 ----- 12 6 13 Enable types14 15 >>> lpf = self.portal.portal_types['Large Plone Folder']16 >>> lpf_allow = lpf.global_allow17 >>> lpf.global_allow = True18 19 >>> n = self.portal.portal_types['Name']20 >>> n_allow = n.global_allow21 >>> n.global_allow = True22 23 Alias the test folder24 25 7 >>> folder = self.folder 26 27 Containers28 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_MAX33 8 34 9 … … 36 11 ------------- 37 12 13 >>> from Products.PleiadesEntity.Extensions.loader import format_listofstrings 38 14 >>> format_listofstrings([]) 39 15 u'' … … 45 21 u'x, y and z' 46 22 23 >>> from Products.PleiadesEntity.Extensions.xmlutil import purifyText 47 24 >>> purifyText(u'aaa') == u'aaa' 48 25 True … … 55 32 --------------- 56 33 34 >>> TEST_DATA = self.test_params.TEST_DATA 35 >>> from Products.PleiadesEntity.Extensions.loader import load_place 57 36 >>> r = load_place(folder, "%s/timetwister.xml" % TEST_DATA) 58 >>> int(r['place_id']) >= BA_ID_MAX59 True60 37 >>> r['name_ids'] 61 38 ['time-twister', 'tome-twirling'] … … 67 44 >>> len(tps) 68 45 2 69 >>> tps[0].Title 46 >>> tps0 = tps[0].getObject() 47 >>> tps0.Title() 70 48 'Attested: Classical (550 - 330 BC)' 71 >>> tps [0].getId49 >>> tps0.getId() 72 50 'classical' 73 >>> tps [0].getAttestationConfidence51 >>> tps0.getAttestationConfidence() 74 52 'confident' 75 53 76 >>> tps[1].Title 54 >>> tps1 = tps[1].getObject() 55 >>> tps1.Title() 77 56 'Attested: Hellenistic/Republican (330 - 30 BC)?' 78 >>> tps [1].getId57 >>> tps1.getId() 79 58 'hellenistic-republican' 80 >>> tps [1].getAttestationConfidence59 >>> tps1.getAttestationConfidence() 81 60 'less-confident' 82 61 … … 85 64 >>> len(tps) 86 65 2 87 >>> tps[0].Title 66 >>> tps0 = tps[0].getObject() 67 >>> tps0.Title() 88 68 'Attested: Roman (30 BC - AD 300) - inferred' 89 >>> tps [0].getId69 >>> tps0.getId() 90 70 'roman' 91 >>> tps [0].getAttestationConfidence71 >>> tps0.getAttestationConfidence() 92 72 'confident-inferred' 93 94 >>> tps[1].Title 73 74 >>> tps1 = tps[1].getObject() 75 >>> tps1.Title() 95 76 'Attested: Late Antique (AD 300 - 625)? - inferred' 96 >>> tps [1].getId77 >>> tps1.getId() 97 78 'late-antique' 98 >>> tps [1].getAttestationConfidence79 >>> tps1.getAttestationConfidence() 99 80 'less-confident-inferred' 100 81 … … 106 87 >>> len(tps) 107 88 5 108 >>> tps[0].Title 89 >>> tps0 = tps[0].getObject() 90 >>> tps0.Title() 109 91 'Attested: Archaic (pre-550 BC)' 110 >>> tps [0].getId92 >>> tps0.getId() 111 93 'archaic' 112 >>> tps [0].getAttestationConfidence94 >>> tps0.getAttestationConfidence() 113 95 'confident' 114 115 >>> tps[1].Title 96 97 >>> tps1 = tps[1].getObject() 98 >>> tps1.Title() 116 99 'Attested: Classical (550 - 330 BC)' 117 >>> tps [1].getId100 >>> tps1.getId() 118 101 'classical' 119 >>> tps [1].getAttestationConfidence102 >>> tps1.getAttestationConfidence() 120 103 'confident' 121 122 >>> tps[2].Title 104 105 >>> tps2 = tps[2].getObject() 106 >>> tps2.Title() 123 107 'Attested: Hellenistic/Republican (330 - 30 BC)?' 124 >>> tps [2].getId108 >>> tps2.getId() 125 109 '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() 127 127 'less-confident' 128 128 129 >>> tps[3].Title130 'Attested: Roman (30 BC - AD 300)'131 >>> tps[3].getId132 'roman'133 >>> tps[3].getAttestationConfidence134 'confident'135 136 >>> tps[4].Title137 'Attested: Late Antique (AD 300 - 625)?'138 >>> tps[4].getId139 'late-antique'140 >>> tps[4].getAttestationConfidence141 'less-confident'142 PleiadesEntity/trunk/tests/Vocabularies.txt
r706 r1249 14 14 'Types of Places Distinguished in AWMC Publications' 15 15 >>> len([obj for obj in v.contentValues() if obj.meta_type == "VdexTerm"]) 16 5 116 52 17 17 18 18 Test ancient name types vocabulary … … 23 23 'Types of Historical Names Distinguished in AWMC Publications' 24 24 >>> len([obj for obj in v.contentValues() if obj.meta_type == "VdexTerm"]) 25 325 4 26 26 27 27 Test ancient name languages vocabulary PleiadesEntity/trunk/tests/test_docfiles.py
r1248 r1249 6 6 from Testing import ZopeTestCase as ztc 7 7 from Products.PloneTestCase import PloneTestCase as ptc 8 from Products.PloneTestCase.layer import onsetup, PloneSite 8 from Products.PloneTestCase.layer import onsetup, PloneSite, ZCMLLayer 9 9 import _testing 10 10 … … 14 14 ptc.setupPloneSite(products=['Archetypes', 'ATVocabularyManager', 'Geographer', 'PleiadesEntity']) 15 15 16 optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE16 optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE # | doctest.REPORT_ONLY_FIRST_FAILURE 17 17 18 18 class PleiadesEntityTestCase(ptc.PloneTestCase): 19 19 20 layer = PloneSite 21 20 22 def afterSetUp(self): 21 23 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 22 28 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 42 integration_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 53 functional_tests = [ 54 'LocationViews.txt', 55 'NameViews.txt' 56 ] 57 58 def make_integration_suite(name): 59 return ztc.ZopeDocFileSuite( 60 name, 61 package='Products.PleiadesEntity.tests', 62 test_class=PleiadesEntityTestCase, 63 optionflags=optionflags, 64 ) 65 66 def make_functional_suite(name): 67 return ztc.FunctionalDocFileSuite( 68 name, 69 package='Products.PleiadesEntity.tests', 70 test_class=PleiadesEntityTestCase, 71 optionflags=optionflags, 72 ) 23 73 24 74 def 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 ) 57 79 58 80 if __name__ == '__main__': 59 81 unittest.main(defaultTest='test_suite') 82
