[2382] | 1 | # |
---|
| 2 | # Tests for quintagroup.plonegooglesitemaps |
---|
| 3 | # |
---|
| 4 | |
---|
| 5 | import re, sys |
---|
| 6 | from urllib import urlencode |
---|
| 7 | from StringIO import StringIO |
---|
| 8 | import unittest |
---|
| 9 | |
---|
| 10 | from zope.testing import doctestunit |
---|
[2538] | 11 | from zope.interface import Interface |
---|
[2382] | 12 | from zope.component import testing |
---|
[2841] | 13 | from zope.interface import alsoProvides |
---|
[2382] | 14 | from Testing import ZopeTestCase as ztc |
---|
| 15 | |
---|
| 16 | from Products.Five import zcml |
---|
| 17 | from Products.Five import fiveconfigure |
---|
| 18 | |
---|
| 19 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
[2555] | 20 | from Products.PloneTestCase.layer import onsetup |
---|
[2382] | 21 | from Products.PloneTestCase.layer import PloneSite |
---|
[2394] | 22 | from Products.PloneTestCase.setup import portal_owner |
---|
| 23 | from Products.PloneTestCase.setup import default_password |
---|
[2382] | 24 | |
---|
| 25 | from XMLParser import parse, hasURL |
---|
| 26 | |
---|
| 27 | import quintagroup.plonegooglesitemaps |
---|
[2386] | 28 | from quintagroup.plonegooglesitemaps.config import PROJECTNAME |
---|
[2382] | 29 | from quintagroup.plonegooglesitemaps.config import ping_googlesitemap |
---|
[2841] | 30 | from quintagroup.plonegooglesitemaps.config import SUPPORT_BLAYER |
---|
[2538] | 31 | from quintagroup.plonegooglesitemaps.browser import mobilesitemapview |
---|
[2841] | 32 | from quintagroup.plonegooglesitemaps.interfaces import IGoogleSitemapsLayer |
---|
[2382] | 33 | |
---|
| 34 | quintagroup.plonegooglesitemaps.config.testing = 1 |
---|
| 35 | quintagroup.plonegooglesitemaps.config.UPDATE_CATALOG = True |
---|
| 36 | |
---|
[2555] | 37 | PRODUCT = 'quintagroup.plonegooglesitemaps' |
---|
[2382] | 38 | |
---|
[2555] | 39 | @onsetup |
---|
| 40 | def setup_product(): |
---|
| 41 | """Set up the package and its dependencies. |
---|
| 42 | |
---|
| 43 | The @onsetup decorator causes the execution of this body to be |
---|
| 44 | deferred until the setup of the Plone site testing layer. We could |
---|
| 45 | have created our own layer, but this is the easiest way for Plone |
---|
| 46 | integration tests. |
---|
| 47 | """ |
---|
| 48 | fiveconfigure.debug_mode = True |
---|
| 49 | import quintagroup.plonegooglesitemaps |
---|
| 50 | zcml.load_config('configure.zcml', quintagroup.plonegooglesitemaps) |
---|
| 51 | zcml.load_config('overrides.zcml', quintagroup.plonegooglesitemaps) |
---|
| 52 | fiveconfigure.debug_mode = False |
---|
| 53 | |
---|
| 54 | ztc.installPackage(PRODUCT) |
---|
| 55 | |
---|
| 56 | setup_product() |
---|
| 57 | ptc.setupPloneSite( products=(PRODUCT,)) |
---|
| 58 | |
---|
| 59 | |
---|
[2538] | 60 | class IMobileMarker(Interface): |
---|
| 61 | """Test Marker interface for mobile objects""" |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | class MixinTestCase(object): |
---|
[2382] | 65 | """ Define layer and common afterSetup method with package installation. |
---|
| 66 | Package installation on plone site setup impossible because of |
---|
| 67 | five's registerPackage directive not recognized on module initializing. |
---|
| 68 | """ |
---|
| 69 | layer = PloneSite |
---|
| 70 | |
---|
| 71 | def afterSetUp(self): |
---|
| 72 | self.loginAsPortalOwner() |
---|
[2538] | 73 | self.workflow = self.portal.portal_workflow |
---|
| 74 | self.orig_mobile_ifaces = None |
---|
[2841] | 75 | alsoProvides(self.portal.REQUEST, IGoogleSitemapsLayer) |
---|
[2382] | 76 | |
---|
[2538] | 77 | def patchMobile(self): |
---|
| 78 | # patch mobile sitemap view |
---|
| 79 | self.orig_mobile_ifaces = mobilesitemapview.MOBILE_INTERFACES |
---|
| 80 | mobilesitemapview.MOBILE_INTERFACES = [IMobileMarker.__identifier__,] |
---|
[2382] | 81 | |
---|
[2538] | 82 | def beforeTearDown(self): |
---|
| 83 | if self.orig_mobile_ifaces is not None: |
---|
| 84 | mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces |
---|
| 85 | |
---|
| 86 | |
---|
[2382] | 87 | class TestCase(MixinTestCase, ptc.PloneTestCase): |
---|
| 88 | """ For unit tests """ |
---|
| 89 | |
---|
[2538] | 90 | |
---|
[2382] | 91 | class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): |
---|
| 92 | """ For functional tests """ |
---|
| 93 | |
---|
[2538] | 94 | def afterSetUp(self): |
---|
| 95 | super(FunctionalTestCase, self).afterSetUp() |
---|
| 96 | self.auth = "%s:%s" % (portal_owner, default_password) |
---|
| 97 | |
---|