[2870] | 1 | import unittest |
---|
[3003] | 2 | import transaction |
---|
[2870] | 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 |
---|
[3003] | 10 | from Products.PloneTestCase import setup as ptc_setup |
---|
[2870] | 11 | from Products.PloneTestCase.layer import PloneSite |
---|
[3003] | 12 | import quintagroup.analytics |
---|
[2870] | 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', |
---|
[3003] | 21 | quintagroup.analytics) |
---|
[2870] | 22 | fiveconfigure.debug_mode = False |
---|
[3003] | 23 | ztc.installPackage('quintagroup.analytics') |
---|
| 24 | app = ztc.app() |
---|
| 25 | portal = app[ptc_setup.portal_name] |
---|
[2870] | 26 | |
---|
[3003] | 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 | |
---|
[2870] | 34 | @classmethod |
---|
| 35 | def tearDown(cls): |
---|
| 36 | pass |
---|
| 37 | |
---|
| 38 | |
---|
[3003] | 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 | |
---|
[2870] | 59 | def test_suite(): |
---|
[3003] | 60 | from unittest import TestSuite, makeSuite |
---|
[2870] | 61 | |
---|
[3003] | 62 | test_suite = unittest.TestSuite([ |
---|
| 63 | |
---|
[2870] | 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 | |
---|
[3003] | 85 | test_suite.addTest(makeSuite(TestQAInstallation)) |
---|
| 86 | return test_suite |
---|
| 87 | |
---|
[2870] | 88 | if __name__ == '__main__': |
---|
| 89 | unittest.main(defaultTest='test_suite') |
---|