Skip to content

Commit

Permalink
fixed package installation; added basic test cases for install/uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jul 23, 2012
1 parent 479e2ea commit 4017a42
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/collective/weather/browser/configure.zcml
Expand Up @@ -9,7 +9,7 @@
name="collective.weather.icons"
directory="icons"
/>

<!--
<browser:resourceDirectory
name="collective.weather.js"
directory="js"
Expand All @@ -19,7 +19,7 @@
name="collective.weather.css"
directory="css"
/>

-->
<browser:page
name="weather-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
Expand Down
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions src/collective/weather/config.py
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

PROJECTNAME = 'collective.weather'
11 changes: 9 additions & 2 deletions src/collective/weather/configure.zcml
Expand Up @@ -18,6 +18,13 @@
description="Installs the collective.weather package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<!-- -*- extra stuff goes here -*- -->


<genericsetup:registerProfile
name="uninstall"
title="collective.weather uninstall"
directory="profiles/uninstall"
description="Uninstall profile for the collective.weather package."
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

</configure>
3 changes: 3 additions & 0 deletions src/collective/weather/profiles/uninstall/registry.xml
@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<registry>
</registry>
34 changes: 19 additions & 15 deletions src/collective/weather/testing.py
@@ -1,27 +1,31 @@
from plone.app.testing import PLONE_FIXTURE
# -*- coding: utf-8 -*-

from plone.app.testing import PloneSandboxLayer
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import IntegrationTesting
from plone.app.testing import FunctionalTesting
from plone.app.testing import applyProfile

from zope.configuration import xmlconfig

class CollectiveWeather(PloneSandboxLayer):
class Fixture(PloneSandboxLayer):

defaultBases = (PLONE_FIXTURE, )
defaultBases = (PLONE_FIXTURE,)

def setUpZope(self, app, configurationContext):
# Load ZCML for this package
# Load ZCML
import collective.weather
xmlconfig.file('configure.zcml',
collective.weather,
context=configurationContext)

self.loadZCML(package=collective.weather)

def setUpPloneSite(self, portal):
applyProfile(portal, 'collective.weather:default')
# Install into Plone site using portal_setup
self.applyProfile(portal, 'collective.weather:default')


COLLECTIVE_WEATHER_FIXTURE = CollectiveWeather()
COLLECTIVE_WEATHER_INTEGRATION_TESTING = \
IntegrationTesting(bases=(COLLECTIVE_WEATHER_FIXTURE, ),
name="CollectiveWeather:Integration")
FIXTURE = Fixture()
INTEGRATION_TESTING = IntegrationTesting(
bases=(FIXTURE,),
name='collective.weather:Integration',
)
FUNCTIONAL_TESTING = FunctionalTesting(
bases=(FIXTURE,),
name='collective.weather:Functional',
)
25 changes: 0 additions & 25 deletions src/collective/weather/tests/test_example.py

This file was deleted.

35 changes: 35 additions & 0 deletions src/collective/weather/tests/test_setup.py
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-

import unittest2 as unittest

from plone.app.testing import TEST_USER_ID
from plone.app.testing import setRoles

from collective.weather.config import PROJECTNAME
from collective.weather.testing import INTEGRATION_TESTING


class InstallTestCase(unittest.TestCase):

layer = INTEGRATION_TESTING

def setUp(self):
self.portal = self.layer['portal']

def test_installed(self):
qi = getattr(self.portal, 'portal_quickinstaller')
self.assertTrue(qi.isProductInstalled(PROJECTNAME))


class UninstallTest(unittest.TestCase):

layer = INTEGRATION_TESTING

def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.qi = getattr(self.portal, 'portal_quickinstaller')
self.qi.uninstallProducts(products=[PROJECTNAME])

def test_uninstalled(self):
self.assertFalse(self.qi.isProductInstalled(PROJECTNAME))

0 comments on commit 4017a42

Please sign in to comment.