Changeset 3599 in products for quintagroup.canonicalpath/trunk/quintagroup
- Timestamp:
- Oct 24, 2012 2:57:02 PM (12 years ago)
- Location:
- quintagroup.canonicalpath/trunk/quintagroup/canonicalpath
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py
r3145 r3599 15 15 PROPERTY_LINK = "canonical_link" 16 16 17 _is_canonical = re.compile( 18 r"\S*$" # non space and no new line(should be pickier) 19 ).match 17 _is_canonical = re.compile(r"\S*$").match # non space and no new line(should be pickier) 20 18 21 19 -
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/interfaces.py
r3145 r3599 6 6 """ 7 7 8 canonical_path = Attribute("canonical_path", 8 canonical_path = Attribute( 9 "canonical_path", 9 10 "canonical_path - for the object. Adapter must implement " 10 11 "*setter* and *getter* for the attribute") … … 15 16 """ 16 17 17 canonical_link = Attribute("canonical_link", 18 canonical_link = Attribute( 19 "canonical_link", 18 20 "canonical_link - for the object. Adapter must implement " 19 21 "*setter* and *getter* for the attribute") -
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/tests.py
r3146 r3599 89 89 wrapper = self.get_indexable_wrapper(self.my_doc) 90 90 self.assertTrue(hasattr(wrapper, 'canonical_path'), 91 "'canonical_path' attribute not accessible with " \91 "'canonical_path' attribute not accessible with " 92 92 "indexer wrapper for Document object") 93 93 … … 95 95 wrapper = self.get_indexable_wrapper(self.my_doc) 96 96 self.assertTrue(hasattr(wrapper, 'canonical_link'), 97 "'canonical_link' attribute not accessible with " \97 "'canonical_link' attribute not accessible with " 98 98 "indexer wrapper for Document object") 99 99 … … 109 109 110 110 self.mydoc_cp = '/' + '/'.join(self.purl.getRelativeContentPath( 111 111 self.my_doc)) 112 112 self.portal_cp = '/' + '/'.join(self.purl.getRelativeContentPath( 113 113 self.portal)) 114 114 115 115 def testRegistration4Portal(self): 116 116 cpadapter = queryAdapter(self.portal, ICanonicalPath) 117 117 self.assertFalse(cpadapter is None, 118 "Can't get canonical path adapter for the plone site object") 118 "Can't get canonical path adapter for the plone" 119 " site object") 119 120 120 121 def testRegistration4AT(self): 121 122 cpadapter = queryAdapter(self.my_doc, ICanonicalPath) 122 123 self.assertFalse(cpadapter is None, 123 "Can't get canonical path adapter for the Document object") 124 "Can't get canonical path adapter for the Document" 125 " object") 124 126 125 127 def testGetDefault4Portal(self): 126 128 cpadapter = queryAdapter(self.portal, ICanonicalPath) 127 129 self.assertTrue(cpadapter.canonical_path == self.portal_cp, 128 "Canonical path adapter return '%s' for portal, must be: '%s'" % ( 129 cpadapter.canonical_path, self.portal_cp)) 130 "Canonical path adapter return '%s' for portal," 131 " must be: '%s'" % (cpadapter.canonical_path, 132 self.portal_cp)) 130 133 131 134 def testGetDefault4AT(self): 132 135 cpadapter = queryAdapter(self.my_doc, ICanonicalPath) 133 136 self.assertTrue(cpadapter.canonical_path == self.mydoc_cp, 134 "Canonical path adapter return '%s' for document, "\ 135 "must be: '%s'" % (cpadapter.canonical_path, self.mydoc_cp)) 137 "Canonical path adapter return '%s' for document, " 138 "must be: '%s'" % (cpadapter.canonical_path, 139 self.mydoc_cp)) 136 140 137 141 def testSet4Portal(self): … … 142 146 prop = self.portal.getProperty(PROPERTY_PATH, None) 143 147 self.assertTrue(prop == newcp, 144 "Canonical path adapter setter NOT SET new '%s' value to '%s' " \ 145 "propery for the portal" % (newcp, PROPERTY_PATH)) 148 "Canonical path adapter setter NOT SET new '%s' value" 149 " to '%s' propery for the portal" % (newcp, 150 PROPERTY_PATH)) 146 151 147 152 self.assertTrue(cpadapter.canonical_path == newcp, 148 "Canonical path adapter GET '%s' canonical_path, for portal, " \ 149 "must be: '%s'" % (cpadapter.canonical_path, newcp)) 153 "Canonical path adapter GET '%s' canonical_path, for" 154 " portal, must be: '%s'" % (cpadapter.canonical_path, 155 newcp)) 150 156 151 157 def testSet4AT(self): … … 156 162 prop = self.my_doc.getProperty(PROPERTY_PATH, None) 157 163 self.assertTrue(prop == newcp, 158 "Canonical path adapter setter NOT SET new '%s' value to '%s' " \ 159 "propery for the Document" % (newcp, PROPERTY_PATH)) 164 "Canonical path adapter setter NOT SET new '%s' value" 165 " to '%s' propery for the Document" % (newcp, 166 PROPERTY_PATH)) 160 167 161 168 self.assertTrue(cpadapter.canonical_path == newcp, 162 "Canonical path adapter GET '%s' canonical_path, for Document, " \ 163 "must be: '%s'" % (cpadapter.canonical_path, newcp)) 169 "Canonical path adapter GET '%s' canonical_path, for " 170 "Document, must be: '%s'" % (cpadapter.canonical_path, 171 newcp)) 164 172 165 173 def testValidationWrong(self): … … 172 180 else: 173 181 raise self.failureException, "InvalidValue not raised when " \ 174 182 "'%s' wrong value try to set" % wrong 175 183 176 184 def testValidationGood(self): … … 187 195 del cpadapter.canonical_path 188 196 self.assertFalse(hasprop(PROPERTY_PATH), 189 "Not deleted Canonical path customization property for the portal") 197 "Not deleted Canonical path customization property " 198 "for the portal") 190 199 191 200 def testDelCustomization(self): … … 196 205 del cpadapter.canonical_path 197 206 self.assertTrue(cpadapter.canonical_path == self.portal_cp, 198 "After deleted Canonical path customization property not set to"199 "default value for the portal")207 "After deleted Canonical path customization property " 208 "not set to default value for the portal") 200 209 201 210 … … 214 223 cladapter = queryAdapter(self.portal, ICanonicalLink) 215 224 self.assertFalse(cladapter is None, 216 "Can't get canonical link adapter for the plone site object") 225 "Can't get canonical link adapter for the plone site " 226 "object") 217 227 218 228 def testRegistration4AT(self): 219 229 cladapter = queryAdapter(self.my_doc, ICanonicalLink) 220 230 self.assertFalse(cladapter is None, 221 "Can't get canonical link adapter for the Document object") 231 "Can't get canonical link adapter for the Document " 232 " object") 222 233 223 234 def testGetDefault4Portal(self): 224 235 cladapter = queryAdapter(self.portal, ICanonicalLink) 225 236 self.assertTrue(cladapter.canonical_link == self.purl(), 226 "Canonical link adapter return '%s' for portal, must be: '%s'" % (227 cladapter.canonical_link, self.purl()))237 "Canonical link adapter return '%s' for portal, must " 238 "be: '%s'" % (cladapter.canonical_link, self.purl())) 228 239 229 240 def testGetDefault4AT(self): 230 241 cladapter = queryAdapter(self.my_doc, ICanonicalLink) 231 242 self.assertTrue(cladapter.canonical_link == self.mydoc_cl, 232 "Canonical link adapter return '%s' for document, "\ 233 "must be: '%s'" % (cladapter.canonical_link, self.mydoc_cl)) 243 "Canonical link adapter return '%s' for document, " 244 "must be: '%s'" % (cladapter.canonical_link, 245 self.mydoc_cl)) 234 246 235 247 def testSet4Portal(self): … … 240 252 prop = self.portal.getProperty(PROPERTY_LINK, None) 241 253 self.assertTrue(prop == newcl, 242 "Canonical link adapter setter NOT SET new '%s' value to '%s' " \ 243 "propery for the portal" % (newcl, PROPERTY_LINK)) 254 "Canonical link adapter setter NOT SET new '%s' value " 255 "to '%s' propery for the portal" % (newcl, 256 PROPERTY_LINK)) 244 257 245 258 self.assertTrue(cladapter.canonical_link == newcl, 246 "Canonical link adapter GET '%s' canonical_link, for portal, " \ 247 "must be: '%s'" % (cladapter.canonical_link, newcl)) 259 "Canonical link adapter GET '%s' canonical_link, for " 260 "portal, must be: '%s'" % (cladapter.canonical_link, 261 newcl)) 248 262 249 263 def testSet4AT(self): … … 254 268 prop = self.my_doc.getProperty(PROPERTY_LINK, None) 255 269 self.assertTrue(prop == newcl, 256 "Canonical link adapter setter NOT SET new '%s' value to '%s' " \ 257 "propery for the Document" % (newcl, PROPERTY_LINK)) 270 "Canonical link adapter setter NOT SET new '%s' value " 271 "to '%s' propery for the Document" % (newcl, 272 PROPERTY_LINK)) 258 273 259 274 self.assertTrue(cladapter.canonical_link == newcl, 260 "Canonical link adapter GET '%s' canonical_link, for Document, " \ 261 "must be: '%s'" % (cladapter.canonical_link, newcl)) 275 "Canonical link adapter GET '%s' canonical_link, for " 276 "Document, must be: '%s'" % (cladapter.canonical_link, 277 newcl)) 262 278 263 279 def testValidationWrong(self): … … 285 301 del cladapter.canonical_link 286 302 self.assertFalse(hasprop(PROPERTY_LINK), 287 "Not deleted Canonical link customization property for the portal") 303 "Not deleted Canonical link customization property " 304 "for the portal") 288 305 289 306 def test_DelCustomization(self): … … 294 311 del cladapter.canonical_link 295 312 self.assertTrue(cladapter.canonical_link == self.purl(), 296 "After deleted Canonical link customization property not set to"297 "default value for the portal")313 "After deleted Canonical link customization property " 314 "not set to default value for the portal") 298 315 299 316 ## … … 348 365 result = ICanonicalLink(item).canonical_link 349 366 expect = "http://domain.com/www/some/path" 350 self.assertEqual(result, expect, "Got %s canonical link, " \367 self.assertEqual(result, expect, "Got %s canonical link, " 351 368 "expect: %s" % (result, expect)) 352 369 # 2. canonical path propery mast be delete from the object … … 361 378 result = ICanonicalLink(item).canonical_link 362 379 expect = "http://domain.com/www/some/path" 363 self.assertEqual(result, expect, "Got %s canonical link, " \380 self.assertEqual(result, expect, "Got %s canonical link, " 364 381 "expect: %s" % (result, expect)) 365 382 # 2. custom_property mast be deleted from the object … … 397 414 assert logs != "" 398 415 self.assertEqual(logs == logs2, True, 399 "logs not equal: \"%s\" != \"%s\"" % (logs, logs2))416 "logs not equal: \"%s\" != \"%s\"" % (logs, logs2)) 400 417 self.convertor.convertIPathToLink(bad) 401 418 logs3 = self.convertor.getLogs() 402 self.assertEqual(logs3 > logs2, True, 403 "Log was not updated - last: \"%s\", previous: \"%s\"" % (logs3, 404 logs2)) 419 self.assertEqual(logs3 > logs2, True, "Log was not updated - " 420 "last: \"%s\", previous: \"%s\"" % (logs3, logs2)) 405 421 406 422 def test_loggingCleanup(self): … … 427 443 item = ProperyAndTraverseProvider("test") 428 444 self.assertNotEqual(queryAdapter(item, ICanonicalLink), None, 429 self.cant % ICanonicalLink.__name__ + "IPropertyManager and "\ 430 "ITraversable.") 445 self.cant % ICanonicalLink.__name__ + 446 "IPropertyManager and " 447 "ITraversable.") 431 448 self.assertNotEqual(queryAdapter(item, ICanonicalPath), None, 432 self.cant % ICanonicalPath.__name__ + "IPropertyManager and "\ 433 "ITraversable.") 449 self.cant % ICanonicalPath.__name__ + 450 "IPropertyManager and " 451 "ITraversable.") 434 452 435 453 def test_Traversable(self): … … 439 457 item = TraverseProvider("test") 440 458 self.assertNotEqual(queryAdapter(item, ICanonicalLink), None, 441 self.cant % ICanonicalLink.__name__ + "only ITraversable.") 459 self.cant % ICanonicalLink.__name__ + 460 "only ITraversable.") 442 461 self.assertNotEqual(queryAdapter(item, ICanonicalPath), None, 443 self.cant % ICanonicalPath.__name__ + "only ITraversable.") 462 self.cant % ICanonicalPath.__name__ + 463 "only ITraversable.") 444 464 445 465 def test_PropertyManager(self): … … 451 471 item = PropertyManagerProvider("test") 452 472 self.assertEqual(queryAdapter(item, ICanonicalLink), None, 453 self.doget % ICanonicalLink.__name__ + "only IPropertyManager.") 473 self.doget % ICanonicalLink.__name__ + 474 "only IPropertyManager.") 454 475 self.assertEqual(queryAdapter(item, ICanonicalPath), None, 455 self.doget % ICanonicalPath.__name__ + "only IPropertyManager.") 476 self.doget % ICanonicalPath.__name__ + 477 "only IPropertyManager.") 456 478 457 479 def test_NotProvider(self): … … 460 482 item = NotProvider("test") 461 483 self.assertEqual(queryAdapter(item, ICanonicalLink), None, 462 self.doget % ICanonicalLink.__name__ + "nor ITraversabe not "\ 463 "IPropertyManager.") 484 self.doget % ICanonicalLink.__name__ + 485 "nor ITraversabe not " 486 "IPropertyManager.") 464 487 self.assertEqual(queryAdapter(item, ICanonicalPath), None, 465 self.doget % ICanonicalPath.__name__ + "nor ITraversabe not "\ 466 "IPropertyManager.") 488 self.doget % ICanonicalPath.__name__ + 489 "nor ITraversabe not " 490 "IPropertyManager.") 467 491 468 492 … … 474 498 unittest.makeSuite(TestConvertor), 475 499 unittest.makeSuite(TestAdaptersRegistration), 476 500 ]) 477 501 478 502 if __name__ == '__main__': -
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/upgrades.py
r3146 r3599 6 6 from Acquisition import aq_base, aq_inner 7 7 8 from quintagroup.canonicalpath.interfaces 9 from quintagroup.canonicalpath.interfaces 8 from quintagroup.canonicalpath.interfaces import ICanonicalPath 9 from quintagroup.canonicalpath.interfaces import ICanonicalLink 10 10 from quintagroup.canonicalpath.adapters import PROPERTY_LINK 11 11 from quintagroup.canonicalpath.adapters import PROPERTY_PATH … … 66 66 """ 67 67 src_msg = type(src_iface) in StringTypes and src_iface \ 68 68 or src_iface.__name__ 69 69 msg = "Migrate %s into %s for %s object: " \ 70 70 % (src_msg, dst_iface.__name__, obj.absolute_url()) 71 71 try: 72 72 src = self._getOrMakeAdapter(obj, src_iface) … … 117 117 handler.setLevel(DEBUG) 118 118 formatter = Formatter(fmt="[%(asctime)s]: %(message)s", 119 119 datefmt="%H:%M:%S") 120 120 handler.setFormatter(formatter) 121 121 self._logger = Logger("quintagroup.canonicalpath", NOTSET)
Note: See TracChangeset
for help on using the changeset viewer.