1 | import unittest |
---|
2 | import transaction |
---|
3 | |
---|
4 | from zope.component import testing |
---|
5 | from Testing import ZopeTestCase as ztc |
---|
6 | |
---|
7 | from Products.Five import zcml |
---|
8 | from Products.Five import fiveconfigure |
---|
9 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
10 | from Products.PloneTestCase import setup as ptc_setup |
---|
11 | from Products.PloneTestCase.layer import PloneSite |
---|
12 | import quintagroup.analytics |
---|
13 | ptc.setupPloneSite() |
---|
14 | |
---|
15 | class TestCase(ptc.PloneTestCase): |
---|
16 | class layer(PloneSite): |
---|
17 | @classmethod |
---|
18 | def setUp(cls): |
---|
19 | fiveconfigure.debug_mode = True |
---|
20 | zcml.load_config('configure.zcml', |
---|
21 | quintagroup.analytics) |
---|
22 | fiveconfigure.debug_mode = False |
---|
23 | ztc.installPackage('quintagroup.analytics') |
---|
24 | app = ztc.app() |
---|
25 | portal = app[ptc_setup.portal_name] |
---|
26 | |
---|
27 | # Sets the local site/manager |
---|
28 | ptc_setup._placefulSetUp(portal) |
---|
29 | |
---|
30 | qi = getattr(portal, 'portal_quickinstaller', None) |
---|
31 | qi.installProduct('quintagroup.analytics') |
---|
32 | transaction.commit() |
---|
33 | |
---|
34 | @classmethod |
---|
35 | def tearDown(cls): |
---|
36 | pass |
---|
37 | |
---|
38 | |
---|
39 | #TO DO:===================================================================== |
---|
40 | # add test to verify if QA control panel action is present; |
---|
41 | # add tests for views registration; |
---|
42 | # add tests for every views methods; |
---|
43 | # add doc tests to validate if all needed elements are present on page; |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | class TestQAInstallation(TestCase): |
---|
48 | """ This class veryfies registrations of all needed views and |
---|
49 | actions. |
---|
50 | """ |
---|
51 | |
---|
52 | def test_cp_action_installation(self): |
---|
53 | """Here we are testin control panel action. """ |
---|
54 | control_panel = self.portal.portal_controlpanel |
---|
55 | self.assert_('QAnalytics' in [a.id for a in control_panel.listActions()], |
---|
56 | "Configlet for quintagroup.analitycs isn't registered.") |
---|
57 | |
---|
58 | |
---|
59 | def test_suite(): |
---|
60 | from unittest import TestSuite, makeSuite |
---|
61 | |
---|
62 | test_suite = unittest.TestSuite([ |
---|
63 | |
---|
64 | # Unit tests |
---|
65 | #doctestunit.DocFileSuite( |
---|
66 | # 'README.txt', package='quintagroup.contentstats', |
---|
67 | # setUp=testing.setUp, tearDown=testing.tearDown), |
---|
68 | |
---|
69 | #doctestunit.DocTestSuite( |
---|
70 | # module='quintagroup.contentstats.mymodule', |
---|
71 | # setUp=testing.setUp, tearDown=testing.tearDown), |
---|
72 | |
---|
73 | |
---|
74 | # Integration tests that use PloneTestCase |
---|
75 | #ztc.ZopeDocFileSuite( |
---|
76 | # 'README.txt', package='quintagroup.contentstats', |
---|
77 | # test_class=TestCase), |
---|
78 | |
---|
79 | #ztc.FunctionalDocFileSuite( |
---|
80 | # 'browser.txt', package='quintagroup.contentstats', |
---|
81 | # test_class=TestCase), |
---|
82 | |
---|
83 | ]) |
---|
84 | |
---|
85 | test_suite.addTest(makeSuite(TestQAInstallation)) |
---|
86 | return test_suite |
---|
87 | |
---|
88 | if __name__ == '__main__': |
---|
89 | unittest.main(defaultTest='test_suite') |
---|