Skip to content

Commit

Permalink
Add minimal test for upgrade steps
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed Jun 1, 2018
1 parent 141321a commit efa458d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 47 deletions.
2 changes: 0 additions & 2 deletions src/collective/ifttt/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

<!--<includeDependencies package="." />-->

<include file="upgrades.zcml" />

<browser:jbot
directory="overrides"
layer="collective.ifttt.interfaces.ICollectiveIftttLayer"
Expand Down
9 changes: 0 additions & 9 deletions src/collective/ifttt/browser/upgrades.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/collective/ifttt/browser/upgrades.zcml

This file was deleted.

13 changes: 7 additions & 6 deletions src/collective/ifttt/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class CollectiveIftttLayer(PloneSandboxLayer):

defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,)
defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE, )

def setUpZope(self, app, configurationContext):
# Load any other ZCML that is required for your tests.
Expand All @@ -22,23 +22,24 @@ def setUpZope(self, app, configurationContext):

def setUpPloneSite(self, portal):
applyProfile(portal, 'collective.ifttt:default')
# noinspection PyProtectedMember
portal.portal_setup._profile_upgrade_versions[
'collective.ifttt:default'
] = (u'1000', ) # fake current profile version to allow upgrades


COLLECTIVE_IFTTT_FIXTURE = CollectiveIftttLayer()


COLLECTIVE_IFTTT_INTEGRATION_TESTING = IntegrationTesting(
bases=(COLLECTIVE_IFTTT_FIXTURE,),
bases=(COLLECTIVE_IFTTT_FIXTURE, ),
name='CollectiveIftttLayer:IntegrationTesting',
)


COLLECTIVE_IFTTT_FUNCTIONAL_TESTING = FunctionalTesting(
bases=(COLLECTIVE_IFTTT_FIXTURE,),
bases=(COLLECTIVE_IFTTT_FIXTURE, ),
name='CollectiveIftttLayer:FunctionalTesting',
)


COLLECTIVE_IFTTT_ACCEPTANCE_TESTING = FunctionalTesting(
bases=(
COLLECTIVE_IFTTT_FIXTURE,
Expand Down
36 changes: 23 additions & 13 deletions src/collective/ifttt/tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from collective.ifttt.testing import COLLECTIVE_IFTTT_INTEGRATION_TESTING # noqa
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from collective.ifttt.testing import COLLECTIVE_IFTTT_INTEGRATION_TESTING # noqa

import unittest

Expand All @@ -17,20 +17,33 @@ def setUp(self):
"""Custom shared utility setup for tests."""
self.portal = self.layer['portal']
self.installer = api.portal.get_tool('portal_quickinstaller')
self.setup = api.portal.get_tool('portal_setup')

def test_product_installed(self):
"""Test if collective.ifttt is installed."""
self.assertTrue(self.installer.isProductInstalled(
'collective.ifttt'))
self.assertTrue(self.installer.isProductInstalled('collective.ifttt'))

def test_product_upgrade(self):
"""Test if collective.ifttt can be upgraded."""
self.assertIn(
u'collective.ifttt:default',
self.setup.listProfilesWithUpgrades(),
)
self.assertGreater(
len(self.setup.listUpgrades(u'collective.ifttt:default')),
0,
)
self.setup.upgradeProfile(u'collective.ifttt:default')
self.assertEqual(
len(self.setup.listUpgrades(u'collective.ifttt:default')),
0,
)

def test_browserlayer(self):
"""Test that ICollectiveIftttLayer is registered."""
from collective.ifttt.interfaces import (
ICollectiveIftttLayer)
from collective.ifttt.interfaces import (ICollectiveIftttLayer)
from plone.browserlayer import utils
self.assertIn(
ICollectiveIftttLayer,
utils.registered_layers())
self.assertIn(ICollectiveIftttLayer, utils.registered_layers())


class TestUninstall(unittest.TestCase):
Expand All @@ -47,14 +60,11 @@ def setUp(self):

def test_product_uninstalled(self):
"""Test if collective.ifttt is cleanly uninstalled."""
self.assertFalse(self.installer.isProductInstalled(
'collective.ifttt'))
self.assertFalse(self.installer.isProductInstalled('collective.ifttt'))

def test_browserlayer_removed(self):
"""Test that ICollectiveIftttLayer is removed."""
from collective.ifttt.interfaces import \
ICollectiveIftttLayer
from plone.browserlayer import utils
self.assertNotIn(
ICollectiveIftttLayer,
utils.registered_layers())
self.assertNotIn(ICollectiveIftttLayer, utils.registered_layers())

0 comments on commit efa458d

Please sign in to comment.