Skip to content

Commit

Permalink
Tests: get_installer is always available on 5.2+.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Jun 26, 2024
1 parent 534a3aa commit b302ff8
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/collective/clamav/tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
"""Setup tests for this package."""

from collective.clamav.testing import COLLECTIVE_CLAMAV_INTEGRATION_TESTING # noqa
from collective.clamav.testing import COLLECTIVE_CLAMAV_INTEGRATION_TESTING
from plone import api

import unittest


try:
from plone.base.utils import get_installer
except ImportError:
# Plone 5.2
from Products.CMFPlone.utils import get_installer
except ImportError: # Plone < 5.1
HAS_INSTALLER = False
else:
HAS_INSTALLER = True


class TestSetup(unittest.TestCase):
Expand All @@ -25,12 +24,8 @@ def setUp(self):

def test_product_installed(self):
"""Test if collective.clamav is installed."""
if HAS_INSTALLER:
qi = get_installer(self.portal)
installed = qi.is_product_installed("collective.clamav")
else:
installer = api.portal.get_tool("portal_quickinstaller")
installed = installer.isProductInstalled("collective.clamav")
qi = get_installer(self.portal)
installed = qi.is_product_installed("collective.clamav")
self.assertTrue(installed)

def test_browserlayer(self):
Expand All @@ -47,14 +42,9 @@ class TestUninstall(unittest.TestCase):

def setUp(self):
self.portal = self.layer["portal"]
if HAS_INSTALLER:
qi = get_installer(self.portal)
qi.uninstall_product("collective.clamav")
self.installed = qi.is_product_installed("collective.clamav")
else:
installer = api.portal.get_tool("portal_quickinstaller")
installer.uninstallProducts(["collective.clamav"])
self.installed = installer.isProductInstalled("collective.clamav")
qi = get_installer(self.portal)
qi.uninstall_product("collective.clamav")
self.installed = qi.is_product_installed("collective.clamav")

def test_product_uninstalled(self):
"""Test if collective.clamav is cleanly uninstalled."""
Expand Down

0 comments on commit b302ff8

Please sign in to comment.