Changeset 1705 in products for quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/tests.py
- Timestamp:
- Feb 10, 2010 9:26:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/tests.py
r1704 r1705 3 3 from zope.testing import doctestunit 4 4 from zope.component import testing 5 from zope.component import queryAdapter 5 from zope.component import queryAdapter, queryMultiAdapter 6 from plone.indexer.interfaces import IIndexableObject 6 7 from Testing import ZopeTestCase as ztc 7 8 … … 30 31 31 32 def afterSetUp(self): 33 self.loginAsPortalOwner() 34 self.my_doc = makeContent(self.portal, portal_type='Document', id='my_doc') 32 35 self.purl = getToolByName(self.portal, 'portal_url') 36 self.catalog = getToolByName(self.portal, 'portal_catalog') 37 self.logout() 33 38 34 39 def testAdapter4Portal(self): … … 45 50 46 51 def testAdapter4AT(self): 47 self.loginAsPortalOwner() 48 my_doc = makeContent(self.portal, portal_type='Document', id='my_doc') 49 self.logout() 50 51 cpadapter = queryAdapter(my_doc, ICanonicalPath) 52 cpadapter = queryAdapter(self.my_doc, ICanonicalPath) 52 53 self.assertFalse(cpadapter is None, 53 54 "Can't get canonical path adapter for the Document object") 54 55 55 mydoc_cp = '/'+'/'.join(self.purl.getRelativeContentPath( my_doc))56 mydoc_cp = '/'+'/'.join(self.purl.getRelativeContentPath(self.my_doc)) 56 57 adcp = cpadapter.canonical_path() 57 58 self.assertTrue(adcp == mydoc_cp, "Canonical path adapter return '%s' "\ 58 59 "for document, must be: '%s'" % (adcp, mydoc_cp) ) 59 60 60 class TestInstallation(TestCase):61 61 62 def afterSetUp(self):63 self.qi = self.portal.portal_quickinstaller64 self. qi.installProduct("quintagroup.canonicalpath")62 def testIndexerRegistration(self): 63 wrapper = queryMultiAdapter((self.portal, self.catalog), IIndexableObject) 64 self.assertFalse(wrapper is None, "No indexer registered for portal object") 65 65 66 self.purl = getToolByName(self.portal, 'portal_url') 67 self.catalog = getToolByName(self.portal, 'portal_catalog') 66 wrapper = queryMultiAdapter((self.my_doc, self.catalog), IIndexableObject) 67 self.assertFalse(wrapper is None, "No indexer registered for document object") 68 69 70 71 # class TestInstallation(TestCase): 68 72 69 def testCatalogMetadata(self):70 self.assertTrue('canonical_path' in self.catalog._catalog.names, 71 "'canonical_path' metadata not added to catalog.")73 # def afterSetUp(self): 74 # self.qi = self.portal.portal_quickinstaller 75 # self.qi.installProduct("quintagroup.canonicalpath") 72 76 73 def testIndexer(self): 74 self.loginAsPortalOwner() 75 my_doc = makeContent(self.portal, portal_type='Document', id='my_doc') 76 my_doc.update(title='My document') 77 # self.purl = getToolByName(self.portal, 'portal_url') 78 # self.catalog = getToolByName(self.portal, 'portal_catalog') 77 79 78 cpadapter = queryAdapter(my_doc, ICanonicalPath) 79 cpmydoc = cpadapter.canonical_path() 80 cpbrain = self.catalog(path='/'+my_doc.absolute_url(1))[0].canonical_path 81 self.assertTrue(cpmydoc == cpbrain, 82 "Canonical Path from adapter: '%s' not equals with brains data: '%s'" % ( 83 cpmydoc, cpbrain)) 80 # def testCatalogMetadata(self): 81 # self.assertTrue('canonical_path' in self.catalog._catalog.names, 82 # "'canonical_path' metadata not added to catalog.") 84 83 85 self.logout() 84 # def testIndexer(self): 85 # self.loginAsPortalOwner() 86 # my_doc = makeContent(self.portal, portal_type='Document', id='my_doc') 87 # my_doc.update(title='My document') 86 88 87 def testCatalogUpdateOnInstallation(self): 88 self.loginAsPortalOwner() 89 fp = self.portal['front-page'] 90 cpadapter = queryAdapter(fp, ICanonicalPath) 91 cpfp = cpadapter.canonical_path() 92 cpbrain = self.catalog(path='/'+fp.absolute_url(1))[0].canonical_path 93 self.assertTrue(cpfp == cpbrain, 94 "Catalog not updated on installation: canonical path from adapter: " \ 95 "'%s' not equal to brain data: '%s'" % (cpfp, cpbrain)) 89 # cpadapter = queryAdapter(my_doc, ICanonicalPath) 90 # cpmydoc = cpadapter.canonical_path() 91 # cpbrain = self.catalog(path='/'+my_doc.absolute_url(1))[0].canonical_path 92 # self.assertTrue(cpmydoc == cpbrain, 93 # "Canonical Path from adapter: '%s' not equals with brains data: '%s'" % ( 94 # cpmydoc, cpbrain)) 96 95 97 self.logout() 96 # self.logout() 97 98 # def testCatalogUpdateOnInstallation(self): 99 # self.loginAsPortalOwner() 100 # fp = self.portal['front-page'] 101 # cpadapter = queryAdapter(fp, ICanonicalPath) 102 # cpfp = cpadapter.canonical_path() 103 # cpbrain = self.catalog(path='/'+fp.absolute_url(1))[0].canonical_path 104 # self.assertTrue(cpfp == cpbrain, 105 # "Catalog not updated on installation: canonical path from adapter: " \ 106 # "'%s' not equal to brain data: '%s'" % (cpfp, cpbrain)) 107 108 # self.logout() 98 109 99 110 … … 101 112 return unittest.TestSuite([ 102 113 unittest.makeSuite(TestAdapter), 103 unittest.makeSuite(TestInstallation),114 #unittest.makeSuite(TestInstallation), 104 115 ]) 105 116
Note: See TracChangeset
for help on using the changeset viewer.