source: products/quintagroup.analytics/trunk/quintagroup/analytics/tests.py @ 3003

Last change on this file since 3003 was 3003, checked in by fenix, 13 years ago

added test to verify if configlet is installed properly

File size: 2.7 KB
Line 
1import unittest
2import transaction
3
4from zope.component import testing
5from Testing import ZopeTestCase as ztc
6
7from Products.Five import zcml
8from Products.Five import fiveconfigure
9from Products.PloneTestCase import PloneTestCase as ptc
10from Products.PloneTestCase import setup as ptc_setup
11from Products.PloneTestCase.layer import PloneSite
12import quintagroup.analytics
13ptc.setupPloneSite()
14
15class 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
47class 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
59def 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
88if __name__ == '__main__':
89    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.