source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py @ 2677

Last change on this file since 2677 was 2555, checked in by mylan, 14 years ago

Merged plone4 branch into trunk : revisions 3588-3592 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.plonegooglesitemaps/branches/plone4

........

r3588 | mylan | 2010-06-17 17:57:02 +0300 (Thu, 17 Jun 2010) | 1 line


#130: Fix 'ValueError?: Product factory for Sitemap was invalid' error in tests.

........

r3589 | mylan | 2010-06-17 19:13:57 +0300 (Thu, 17 Jun 2010) | 1 line


#130: updated configlet templates - added plone4 related globals

........

r3590 | mylan | 2010-06-17 20:10:17 +0300 (Thu, 17 Jun 2010) | 1 line


#130: Fixed absence of tabindex in pagetemplates

........

r3591 | mylan | 2010-06-17 20:58:49 +0300 (Thu, 17 Jun 2010) | 1 line


#130: Fixed breakage on testing upgrades

........

r3592 | mylan | 2010-06-17 21:05:56 +0300 (Thu, 17 Jun 2010) | 1 line


#130: Updated history

........

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