-
Notifications
You must be signed in to change notification settings - Fork 6
/
testing.py
102 lines (78 loc) · 2.67 KB
/
testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- coding: utf-8 -*-
from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import login
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_NAME
from plone.testing import z2
import unittest
class PwExpiryLayer(PloneSandboxLayer):
"""
Testing layer for collective.pwexpiry
"""
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
"""
Set up Zope
"""
# Load ZCML
import collective.pwexpiry
self.loadZCML(package=collective.pwexpiry)
self.loadZCML(package=collective.pwexpiry, name="overrides.zcml")
from OFS.Application import install_package
install_package(
app, collective.pwexpiry, collective.pwexpiry.initialize
)
def setUpPloneSite(self, portal):
"""
Set up Plone
"""
# import default profile
applyProfile(portal, "collective.pwexpiry:default")
# Create test content
# 1. Login as user with Manager privilages
setRoles(portal, TEST_USER_ID, ["Manager"])
login(portal, TEST_USER_NAME)
def tearDownZope(self, app):
"""
Tear down Zope
"""
pass
class PwExpiryRobotLayer(PwExpiryLayer):
"""
Testing layer for collective.pwexpiry robot tests
"""
def setUpPloneSite(self, portal):
"""
Set up Plone
"""
# import default profile
applyProfile(portal, "collective.pwexpiry:default")
applyProfile(portal, "collective.pwexpiry:robot_testing")
# Create test content
# 1. Login as user with Manager privilages
setRoles(portal, TEST_USER_ID, ["Manager"])
login(portal, TEST_USER_NAME)
FIXTURE = PwExpiryLayer()
ROBOT_FIXTURE = PwExpiryRobotLayer()
INTEGRATION_TESTING = IntegrationTesting(
bases=(FIXTURE,), name="PwExpiryLayer:Integration"
)
FUNCTIONAL_TESTING = FunctionalTesting(
bases=(FIXTURE,), name="PwExpiryLayer:Functional"
)
ROBOT_TESTING = FunctionalTesting(
bases=(ROBOT_FIXTURE, AUTOLOGIN_LIBRARY_FIXTURE, z2.ZSERVER_FIXTURE),
name="PwExpiryLayer:Robot",
)
class IntegrationTestCase(unittest.TestCase):
"""Base class for integration tests."""
layer = INTEGRATION_TESTING
class FunctionalTestCase(unittest.TestCase):
"""Base class for functional tests."""
layer = FUNCTIONAL_TESTING