Skip to content

Commit

Permalink
Add basic instalation tests (fixes #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Oct 30, 2013
1 parent 296b4d6 commit d1f3cd2
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Solgema/fullcalendar/testing.py
Original file line number Diff line number Diff line change
@@ -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',
)
Empty file.
52 changes: 52 additions & 0 deletions Solgema/fullcalendar/tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
extras_require={
'test': [
'plone.app.testing',
'plone.browserlayer',
'unittest2',
],
},
entry_points="""
Expand Down

0 comments on commit d1f3cd2

Please sign in to comment.