[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 |
---|
| 13 | from Testing import ZopeTestCase as ztc |
---|
| 14 | |
---|
| 15 | from Products.Five import zcml |
---|
| 16 | from Products.Five import fiveconfigure |
---|
| 17 | |
---|
| 18 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
| 19 | from Products.PloneTestCase.layer import PloneSite |
---|
[2394] | 20 | from Products.PloneTestCase.setup import portal_owner |
---|
| 21 | from Products.PloneTestCase.setup import default_password |
---|
[2382] | 22 | |
---|
| 23 | from XMLParser import parse, hasURL |
---|
| 24 | |
---|
| 25 | import quintagroup.plonegooglesitemaps |
---|
[2386] | 26 | from quintagroup.plonegooglesitemaps.config import PROJECTNAME |
---|
[2382] | 27 | from quintagroup.plonegooglesitemaps.config import ping_googlesitemap |
---|
[2538] | 28 | from quintagroup.plonegooglesitemaps.browser import mobilesitemapview |
---|
[2382] | 29 | |
---|
| 30 | quintagroup.plonegooglesitemaps.config.testing = 1 |
---|
| 31 | quintagroup.plonegooglesitemaps.config.UPDATE_CATALOG = True |
---|
| 32 | |
---|
| 33 | |
---|
[2538] | 34 | class IMobileMarker(Interface): |
---|
| 35 | """Test Marker interface for mobile objects""" |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | class MixinTestCase(object): |
---|
[2382] | 39 | """ Define layer and common afterSetup method with package installation. |
---|
| 40 | Package installation on plone site setup impossible because of |
---|
| 41 | five's registerPackage directive not recognized on module initializing. |
---|
| 42 | """ |
---|
| 43 | layer = PloneSite |
---|
| 44 | |
---|
| 45 | def afterSetUp(self): |
---|
| 46 | self.loginAsPortalOwner() |
---|
[2538] | 47 | self.workflow = self.portal.portal_workflow |
---|
| 48 | self.orig_mobile_ifaces = None |
---|
[2382] | 49 | |
---|
[2538] | 50 | def patchMobile(self): |
---|
| 51 | # patch mobile sitemap view |
---|
| 52 | self.orig_mobile_ifaces = mobilesitemapview.MOBILE_INTERFACES |
---|
| 53 | mobilesitemapview.MOBILE_INTERFACES = [IMobileMarker.__identifier__,] |
---|
[2382] | 54 | |
---|
[2538] | 55 | def beforeTearDown(self): |
---|
| 56 | if self.orig_mobile_ifaces is not None: |
---|
| 57 | mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces |
---|
| 58 | |
---|
| 59 | |
---|
[2382] | 60 | class TestCase(MixinTestCase, ptc.PloneTestCase): |
---|
| 61 | """ For unit tests """ |
---|
| 62 | |
---|
[2538] | 63 | |
---|
[2382] | 64 | class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): |
---|
| 65 | """ For functional tests """ |
---|
| 66 | |
---|
[2538] | 67 | def afterSetUp(self): |
---|
| 68 | super(FunctionalTestCase, self).afterSetUp() |
---|
| 69 | self.auth = "%s:%s" % (portal_owner, default_password) |
---|
| 70 | |
---|
[2382] | 71 | # Initialize all needed zcml directives |
---|
| 72 | fiveconfigure.debug_mode = True |
---|
| 73 | from Products import Five, CMFCore, GenericSetup |
---|
| 74 | zcml.load_config('meta.zcml', Five) |
---|
| 75 | zcml.load_config('meta.zcml', CMFCore) |
---|
| 76 | zcml.load_config('meta.zcml', GenericSetup) |
---|
| 77 | zcml.load_config('permissions.zcml', Five) |
---|
| 78 | |
---|
| 79 | # Force quintagroup.plonegooglesitemaps zcml initialization |
---|
| 80 | zcml.load_config('configure.zcml', quintagroup.plonegooglesitemaps) |
---|
| 81 | zcml.load_config('overrides.zcml', quintagroup.plonegooglesitemaps) |
---|
| 82 | fiveconfigure.debug_mode = False |
---|
| 83 | |
---|
| 84 | # Install quintagroup.plonegooglesitemaps package and Plone site |
---|
| 85 | # with the default profile for the package |
---|
| 86 | PRODUCT = 'quintagroup.plonegooglesitemaps' |
---|
| 87 | ptc.installPackage(PRODUCT) |
---|
[2386] | 88 | ptc.setupPloneSite( products=(PRODUCT,)) |
---|