Changeset 2741 in products for quintagroup.plonegooglesitemaps/trunk/quintagroup
- Timestamp:
- Aug 11, 2010 6:31:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSitemaps.py
r2538 r2741 3 3 # 4 4 from base import * 5 from DateTime import DateTime 6 from zope.interface import alsoProvides 7 from zope.publisher.browser import TestRequest 8 5 9 from Products.Archetypes import atapi 6 10 from Products.CMFPlone.utils import _createObjectByType 11 12 from quintagroup.plonegooglesitemaps.browser.sitemapview import SitemapView 13 from quintagroup.plonegooglesitemaps.browser.newssitemapview import NewsSitemapView 14 from quintagroup.plonegooglesitemaps.browser.mobilesitemapview import MobileSitemapView 7 15 8 16 … … 213 221 214 222 223 class TestContextSearch(TestCase): 224 """ Test if sitemaps collect objects from the container, 225 where it added to, but not from the portal root. 226 """ 227 def prepareTestContent(self, smtype, ptypes, ifaces=()): 228 # Create test folder 229 tfolder = _createObjectByType("Folder", self.portal, id="test-folder") 230 # Add SiteMap in the test folder 231 self.sm = _createObjectByType("Sitemap", tfolder, id='sitemap', 232 sitemapType=smtype, portalTypes=ptypes) 233 self.sm.at_post_create_script() 234 # Add content in root and in the test folder 235 pubdate = (DateTime()+1).strftime("%Y-%m-%d") 236 root_content = _createObjectByType(ptypes[0], self.portal, id='root-content') 237 inner_content = _createObjectByType(ptypes[0], tfolder, id='inner-content') 238 for obj in (root_content, inner_content): 239 self.workflow.doActionFor(obj, 'publish') 240 if ifaces: 241 alsoProvides(obj, ifaces) 242 obj.edit(effectiveDate=pubdate) # this also reindex object 243 self.inner_path = '/'.join(inner_content.getPhysicalPath()) 244 245 def testGoogleSitemap(self): 246 self.prepareTestContent("content", ("Document",)) 247 filtered = SitemapView(self.sm, TestRequest()).getFilteredObjects() 248 self.assertEqual(map(lambda x:x.getPath(), filtered), [self.inner_path,]) 249 250 def testNewsSitemap(self): 251 self.prepareTestContent("news", ("News Item",)) 252 filtered = NewsSitemapView(self.sm, TestRequest()).getFilteredObjects() 253 self.assertEqual(map(lambda x:x.getPath(), filtered), [self.inner_path,]) 254 255 def testMobileSitemap(self): 256 self.patchMobile() 257 self.prepareTestContent("content", ("Document",), (IMobileMarker,)) 258 filtered = MobileSitemapView(self.sm, TestRequest()).getFilteredObjects() 259 self.assertEqual(map(lambda x:x.getPath(), filtered), [self.inner_path,]) 260 215 261 216 262 def test_suite(): … … 220 266 suite.addTest(makeSuite(TestSettings)) 221 267 suite.addTest(makeSuite(TestPinging)) 268 suite.addTest(makeSuite(TestContextSearch)) 222 269 return suite 223 270
Note: See TracChangeset
for help on using the changeset viewer.