Skip to content

Commit

Permalink
Merge pull request #70 from collective/maurits-test-60
Browse files Browse the repository at this point in the history
Drop support for Python 3.7 and older. Test on Plone 6.0 and 5.2.
  • Loading branch information
mauritsvanrees authored Jun 21, 2024
2 parents 1cff666 + f54213c commit 14a37cb
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 144 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.7'
plone-version: '5.2'
- python-version: '3.8'
plone-version: '5.2'
- python-version: '3.12'
plone-version: '6.0'

steps:
# git checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

# buildout eggs cache
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: eggs
key: ${{ runner.os }}-py${{ matrix.python-version }}-plone${{ matrix.plone-version }}-${{ hashFiles('*.cfg') }}
Expand All @@ -42,10 +42,8 @@ jobs:
${{ runner.os }}-py${{ matrix.python-version }}-
# python install
- run: pip install virtualenv
- run: pip install wheel
- name: pip install
run: pip install -r requirements.txt
run: pip install -r requirements-${{ matrix.plone-version }}.txt

# buildout
- name: buildout
Expand Down
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ Changelog
4.0.0a2 (unreleased)
--------------------

- Nothing changed yet.
Breaking changes:

- Drop support for Python 3.7 and older. [maurits]

New features:

- Test on Plone 6.0 as well, next to Plone 5.2. [maurits]


4.0.0a1 (2023-04-14)
Expand Down
92 changes: 0 additions & 92 deletions Makefile

This file was deleted.

4 changes: 1 addition & 3 deletions plone-5.2.x.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[buildout]
extends =
base.cfg
https://dist.plone.org/release/5.2.6/versions.cfg
find-links += https://dist.plone.org/thirdparty/
versions=versions
base.cfg

[versions]
black = 21.7b0
Expand Down
4 changes: 4 additions & 0 deletions plone-6.0.x.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[buildout]
extends =
https://dist.plone.org/release/6.0.11.1/versions.cfg
base.cfg
File renamed without changes.
3 changes: 3 additions & 0 deletions requirements-6.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools==69.2.0
zc.buildout==3.0.1
wheel==0.43.0
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"Framework :: Plone :: 5.2",
"Framework :: Plone :: 6.0",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Plone",
"Operating System :: OS Independent",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
Expand All @@ -51,8 +51,7 @@
package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
# Python 3.6 is EOL, but I don't want to break it needlessly.
python_requires=">=3.6",
python_requires=">=3.8",
install_requires=[
'setuptools',
'Products.CMFPlone',
Expand Down
8 changes: 4 additions & 4 deletions src/collective/mailchimp/tests/test_controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_mailchimp_controlpanel_view(self):
(self.portal, self.portal.REQUEST), name="mailchimp-settings"
)
# view = view.__of__(self.portal)
self.failUnless(view())
self.assertTrue(view())

def test_mailchimp_controlpanel_view_protected(self):
from AccessControl import Unauthorized
Expand All @@ -43,7 +43,7 @@ def test_mailchimp_controlpanel_view_protected(self):

def test_mailchimp_in_controlpanel(self):
self.controlpanel = getToolByName(self.portal, "portal_controlpanel")
self.failUnless(
self.assertTrue(
'mailchimp'
in [
a.getAction(self)['id']
Expand All @@ -55,8 +55,8 @@ def test_record_api_key(self):
record = self.registry.records[
'collective.mailchimp.interfaces.IMailchimpSettings.api_key'
]
self.failUnless('api_key' in IMailchimpSettings)
self.assertEquals(record.value, u"")
self.assertTrue('api_key' in IMailchimpSettings)
self.assertEqual(record.value, u"")


class ControlpanelFunctionalTest(unittest.TestCase):
Expand Down
14 changes: 7 additions & 7 deletions src/collective/mailchimp/tests/test_portlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def setUp(self):

def testPortletTypeRegistered(self):
portlet = getUtility(IPortletType, name='portlet.MailChimp')
self.assertEquals(portlet.addview, 'portlet.MailChimp')
self.assertEqual(portlet.addview, 'portlet.MailChimp')

def testInterfaces(self):
portlet = mailchimp.Assignment(name="foo")
self.failUnless(IPortletAssignment.providedBy(portlet))
self.failUnless(IPortletDataProvider.providedBy(portlet.data))
self.assertTrue(IPortletAssignment.providedBy(portlet))
self.assertTrue(IPortletDataProvider.providedBy(portlet.data))

def testInvokeAddview(self):
portlet = getUtility(IPortletType, name='portlet.MailChimp')
Expand All @@ -50,16 +50,16 @@ def testInvokeAddview(self):
addview = mapping.restrictedTraverse('+/' + portlet.addview)
addview.createAndAdd(data={})

self.assertEquals(len(mapping), 1)
self.failUnless(isinstance(mapping.values()[0], mailchimp.Assignment))
self.assertEqual(len(mapping), 1)
self.assertTrue(isinstance(mapping.values()[0], mailchimp.Assignment))

def testInvokeEditView(self):
mapping = PortletAssignmentMapping()
request = self.portal.REQUEST

mapping['foo'] = mailchimp.Assignment(name="foo")
editview = getMultiAdapter((mapping['foo'], request), name='edit')
self.failUnless(isinstance(editview, mailchimp.EditForm))
self.assertTrue(isinstance(editview, mailchimp.EditForm))

def testRenderer(self):
context = self.portal
Expand All @@ -73,7 +73,7 @@ def testRenderer(self):
renderer = getMultiAdapter(
(context, request, view, manager, assignment), IPortletRenderer
)
self.failUnless(isinstance(renderer, mailchimp.Renderer))
self.assertTrue(isinstance(renderer, mailchimp.Renderer))


class TestRenderer(unittest.TestCase):
Expand Down
33 changes: 7 additions & 26 deletions src/collective/mailchimp/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@
COLLECTIVE_MAILCHIMP_INTEGRATION_TESTING,
)
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import get_installer
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID

import unittest


try:
from Products.CMFPlone.factory import _IMREALLYPLONE5

_IMREALLYPLONE5 # noqa
except ImportError:
PLONE_5 = False
else:
PLONE_5 = True

try:
from Products.CMFPlone.utils import get_installer
except ImportError:
get_installer = None


class TestSetup(unittest.TestCase):

layer = COLLECTIVE_MAILCHIMP_INTEGRATION_TESTING
Expand All @@ -37,7 +23,7 @@ def test_browserlayer_available(self):
from plone.browserlayer import utils
from collective.mailchimp.interfaces import ICollectiveMailchimp

self.failUnless(ICollectiveMailchimp in utils.registered_layers())
self.assertTrue(ICollectiveMailchimp in utils.registered_layers())

def test_mailchimp_resource_bundle_available(self):
from zope.component import getUtility
Expand All @@ -54,10 +40,9 @@ def test_mailchimp_resource_bundle_available(self):
def test_mailchimp_css_enabled(self):
portal_url = self.portal.absolute_url()
css = "++resource++collective.mailchimp.stylesheets/mailchimp.css"
url = f"{portal_url}/{css}"
# render the homepage
html = self.portal()
self.assertIn(url, html)
self.assertIn(css, html)


class TestUninstall(unittest.TestCase):
Expand All @@ -66,19 +51,16 @@ class TestUninstall(unittest.TestCase):

def setUp(self):
self.portal = self.layer['portal']
if get_installer:
self.installer = get_installer(self.portal, self.layer['request'])
else:
self.installer = api.portal.get_tool('portal_quickinstaller')
self.installer = get_installer(self.portal, self.layer['request'])
roles_before = api.user.get_roles(TEST_USER_ID)
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.installer.uninstallProducts(['collective.mailchimp'])
self.installer.uninstall_product('collective.mailchimp')
setRoles(self.portal, TEST_USER_ID, roles_before)

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

def test_browserlayer_removed(self):
Expand All @@ -103,10 +85,9 @@ def test_mailchimp_resource_bundle_removed(self):
def test_mailchimp_css_disabled(self):
portal_url = self.portal.absolute_url()
css = "++resource++collective.mailchimp.stylesheets/mailchimp.css"
url = f"{portal_url}/{css}"
# render the homepage
html = self.portal()
self.assertNotIn(url, html)
self.assertNotIn(css, html)


def test_suite():
Expand Down

0 comments on commit 14a37cb

Please sign in to comment.