source: products/quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/base.py @ 2535

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

#206: move mobile sitemap code preparation into base module

  • 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 PloneSite
20from Products.PloneTestCase.setup import portal_owner
21from Products.PloneTestCase.setup import default_password
22
23from XMLParser import parse, hasURL
24
25import quintagroup.plonegooglesitemaps
26from quintagroup.plonegooglesitemaps.config import PROJECTNAME
27from quintagroup.plonegooglesitemaps.config import ping_googlesitemap
28from quintagroup.plonegooglesitemaps.browser import mobilesitemapview
29
30quintagroup.plonegooglesitemaps.config.testing = 1
31quintagroup.plonegooglesitemaps.config.UPDATE_CATALOG = True
32
33
34class IMobileMarker(Interface):
35    """Test Marker interface for mobile objects"""
36
37
38class MixinTestCase(object):
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()
47        self.workflow = self.portal.portal_workflow
48        self.orig_mobile_ifaces = None
49
50    def patchMobile(self):
51        # patch mobile sitemap view
52        self.orig_mobile_ifaces = mobilesitemapview.MOBILE_INTERFACES
53        mobilesitemapview.MOBILE_INTERFACES = [IMobileMarker.__identifier__,]
54
55    def beforeTearDown(self):
56        if self.orig_mobile_ifaces is not None:
57            mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces
58
59
60class TestCase(MixinTestCase, ptc.PloneTestCase):
61    """ For unit tests """
62
63
64class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase):
65    """ For functional tests """
66
67    def afterSetUp(self):
68        super(FunctionalTestCase, self).afterSetUp()
69        self.auth = "%s:%s" % (portal_owner, default_password)
70
71# Initialize all needed zcml directives
72fiveconfigure.debug_mode = True
73from Products import Five, CMFCore, GenericSetup
74zcml.load_config('meta.zcml', Five)
75zcml.load_config('meta.zcml', CMFCore)
76zcml.load_config('meta.zcml', GenericSetup)
77zcml.load_config('permissions.zcml', Five)
78
79# Force quintagroup.plonegooglesitemaps zcml initialization
80zcml.load_config('configure.zcml', quintagroup.plonegooglesitemaps)
81zcml.load_config('overrides.zcml', quintagroup.plonegooglesitemaps)
82fiveconfigure.debug_mode = False
83
84# Install quintagroup.plonegooglesitemaps package and Plone site
85# with the default profile for the package
86PRODUCT = 'quintagroup.plonegooglesitemaps'
87ptc.installPackage(PRODUCT)
88ptc.setupPloneSite( products=(PRODUCT,))
Note: See TracBrowser for help on using the repository browser.