From d1f3cd24736c8f46e76d26ef1a27691bc5ced09a Mon Sep 17 00:00:00 2001 From: hvelarde Date: Tue, 29 Oct 2013 22:19:45 -0200 Subject: [PATCH] Add basic instalation tests (fixes #23) --- Solgema/fullcalendar/testing.py | 30 ++++++++++++++ Solgema/fullcalendar/tests/__init__.py | 0 Solgema/fullcalendar/tests/test_setup.py | 52 ++++++++++++++++++++++++ setup.py | 2 + 4 files changed, 84 insertions(+) create mode 100644 Solgema/fullcalendar/testing.py create mode 100644 Solgema/fullcalendar/tests/__init__.py create mode 100644 Solgema/fullcalendar/tests/test_setup.py diff --git a/Solgema/fullcalendar/testing.py b/Solgema/fullcalendar/testing.py new file mode 100644 index 0000000..5308afd --- /dev/null +++ b/Solgema/fullcalendar/testing.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from plone.app.testing import FunctionalTesting +from plone.app.testing import IntegrationTesting +from plone.app.testing import PLONE_FIXTURE +from plone.app.testing import PloneSandboxLayer + + +class Fixture(PloneSandboxLayer): + + defaultBases = (PLONE_FIXTURE,) + + def setUpZope(self, app, configurationContext): + # Load ZCML + import Solgema.fullcalendar + self.loadZCML(package=Solgema.fullcalendar) + + def setUpPloneSite(self, portal): + # Install into Plone site using portal_setup + self.applyProfile(portal, 'Solgema.fullcalendar:default') + +FIXTURE = Fixture() +INTEGRATION_TESTING = IntegrationTesting( + bases=(FIXTURE,), + name='Solgema.fullcalendar:Integration', +) +FUNCTIONAL_TESTING = FunctionalTesting( + bases=(FIXTURE,), + name='Solgema.fullcalendar:Functional', +) diff --git a/Solgema/fullcalendar/tests/__init__.py b/Solgema/fullcalendar/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Solgema/fullcalendar/tests/test_setup.py b/Solgema/fullcalendar/tests/test_setup.py new file mode 100644 index 0000000..6133f78 --- /dev/null +++ b/Solgema/fullcalendar/tests/test_setup.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.browserlayer.utils import registered_layers +from Solgema.fullcalendar.testing import INTEGRATION_TESTING + +import unittest2 as unittest + +PROJECTNAME = 'Solgema.fullcalendar' + + +class InstallTestCase(unittest.TestCase): + + layer = INTEGRATION_TESTING + + def setUp(self): + self.portal = self.layer['portal'] + self.skins = self.portal['portal_skins'] + + def test_installed(self): + qi = self.portal['portal_quickinstaller'] + self.assertTrue(qi.isProductInstalled(PROJECTNAME)) + + def test_addon_layer(self): + layers = [l.getName() for l in registered_layers()] + self.assertIn('ISolgemaFullcalendarLayer', layers) + + def test_skin_layers(self): + self.assertIn('solgemafullcalendar', self.skins) + + +class UninstallTestCase(unittest.TestCase): + + layer = INTEGRATION_TESTING + + def setUp(self): + self.portal = self.layer['portal'] + self.skins = self.portal['portal_skins'] + setRoles(self.portal, TEST_USER_ID, ['Manager']) + self.qi = self.portal['portal_quickinstaller'] + self.qi.uninstallProducts(products=[PROJECTNAME]) + + def test_uninstalled(self): + self.assertFalse(self.qi.isProductInstalled(PROJECTNAME)) + + def test_addon_layer_removed(self): + layers = [l.getName() for l in registered_layers()] + self.assertNotIn('ISolgemaFullcalendarLayer', layers) + + def test_skin_layers_removed(self): + self.assertNotIn('solgemafullcalendar', self.skins) diff --git a/setup.py b/setup.py index ba4f008..68d3aeb 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,8 @@ extras_require={ 'test': [ 'plone.app.testing', + 'plone.browserlayer', + 'unittest2', ], }, entry_points="""