Skip to content

Commit

Permalink
Merge pull request #49 from torchbox-forks/master
Browse files Browse the repository at this point in the history
Wagtail 4.1 - 5.2
  • Loading branch information
haydngreatnews committed Jan 26, 2024
2 parents da39697 + c23696f commit 255a9cb
Show file tree
Hide file tree
Showing 22 changed files with 1,031 additions and 330 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
pull_request:
branches:
- main
push:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
id: install-dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
id: test-with-tox
run: |
tox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ tests/testapp/var/media/
.coverage
coverage
coverage_html_report/
venv/
94 changes: 78 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,84 @@ cache:
matrix:
# See `Which version combinations to include in Travis test matrix?` in `/docs/README.md`.
include:
- env: TOXENV=py27-dj111-wt112
python: 2.7
- env: TOXENV=py27-dj111-wt113
python: 2.7
- env: TOXENV=py34-dj111-wt113
python: 3.4
- env: TOXENV=py35-dj111-wt113
python: 3.5
- env: TOXENV=py36-dj111-wt112
python: 3.6
- env: TOXENV=py36-dj111-wt113
python: 3.6
- env: TOXENV=py36-dj111-wt2
python: 3.6
- env: TOXENV=py36-dj2-wt2
python: 3.6
- env: TOXENV=py38-dj32-wt41
python: 3.8
- env: TOXENV=py38-dj32-wt42
python: 3.8
- env: TOXENV=py38-dj32-wt50
python: 3.8
- env: TOXENV=py38-dj32-wt51
python: 3.8
- env: TOXENV=py38-dj32-wt52
python: 3.8
- env: TOXENV=py38-dj41-wt41
python: 3.8
- env: TOXENV=py38-dj41-wt42
python: 3.8
- env: TOXENV=py38-dj41-wt50
python: 3.8
- env: TOXENV=py38-dj41-wt51
python: 3.8
- env: TOXENV=py38-dj41-wt52
python: 3.8
- env: TOXENV=py39-dj32-wt41
python: 3.9
- env: TOXENV=py39-dj32-wt42
python: 3.9
- env: TOXENV=py39-dj32-wt50
python: 3.9
- env: TOXENV=py39-dj32-wt51
python: 3.9
- env: TOXENV=py39-dj32-wt52
python: 3.9
- env: TOXENV=py39-dj41-wt41
python: 3.9
- env: TOXENV=py39-dj41-wt42
python: 3.9
- env: TOXENV=py39-dj41-wt50
python: 3.9
- env: TOXENV=py39-dj41-wt51
python: 3.9
- env: TOXENV=py39-dj41-wt52
python: 3.9
- env: TOXENV=py310-dj32-wt41
python: 3.10
- env: TOXENV=py310-dj32-wt42
python: 3.10
- env: TOXENV=py310-dj32-wt50
python: 3.10
- env: TOXENV=py310-dj32-wt51
python: 3.10
- env: TOXENV=py310-dj32-wt52
python: 3.10
- env: TOXENV=py310-dj41-wt41
python: 3.10
- env: TOXENV=py310-dj41-wt42
python: 3.10
- env: TOXENV=py310-dj41-wt50
python: 3.10
- env: TOXENV=py310-dj41-wt51
python: 3.10
- env: TOXENV=py310-dj41-wt52
python: 3.10
- env: TOXENV=py311-dj41-wt41
python: 3.11
- env: TOXENV=py311-dj41-wt42
python: 3.11
- env: TOXENV=py311-dj41-wt50
python: 3.11
- env: TOXENV=py311-dj41-wt51
python: 3.11
- env: TOXENV=py311-dj41-wt52
python: 3.11
- env: TOXENV=py311-dj42-wt50
python: 3.11
- env: TOXENV=py311-dj42-wt51
python: 3.11
- env: TOXENV=py311-dj42-wt52
python: 3.11
- env: TOXENV=py312-dj42-wt52
python: 3.12
install:
- pip install tox coveralls
- gem install coveralls-lcov
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ Changelog

Unreleased
------------------
...
#. Added tests for Wagtail 5.2

2.1 (2023-10-26)
------------------
#. Added Wagtail 5.1 compatibility.

2.0 (2023-07-26)
------------------
#. Added Wagtail 5.0 compatibility.
#. Added Django 4.2 compatibility.
#. Added Python 3.11 compatibility.
#. Removed compatibility for versions of Wagtail below 4.1
#. Removed support for Django 4.0
#. Removed compatibility for Python 3.7

1.0 (2018-03-07)
------------------
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ start: ## Starts the development server.

lint: ## Lint the project.
flake8 wagtailcaptcha tests setup.py
isort --check-only --diff --recursive wagtailcaptcha tests setup.py
isort --check-only --diff wagtailcaptcha tests setup.py

test: ## Test the project.
python ./runtests.py
Expand Down
11 changes: 3 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ Example
.. code-block:: python
from wagtail.contrib.forms.models import AbstractFormField
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.core.fields import RichTextField
# Or, if using Wagtail < 2.0
#from wagtail.wagtailforms.models import AbstractFormField
#from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
#from wagtail.wagtailcore.fields import RichTextField
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.fields import RichTextField
from modelcluster.fields import ParentalKey
from wagtailcaptcha.models import WagtailCaptchaEmailForm
Expand Down
5 changes: 2 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Django/Wagtail combinations as [supported](http://docs.wagtail.io/en/latest/rele

In order to keep for CI build time from growing out of control, not all Python/Django/Wagtail combinations will be tested.

Test as follow:
- All supported Django/Wagtail combinations with Python `2.7` (since it's the only version in the `2.x` series we support).
- All supported Django/Wagtail combinations with the latest supported Python version of the `3.x` series.
Test as follows:
- All supported Django/Wagtail combinations with the latest supported Python version of the `4.x` and `5.x` series.
- The latest supported Django/Wagtail combination for the remaining Python versions.
11 changes: 7 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/env python

from __future__ import absolute_import, unicode_literals

import os
import sys


def run():
from django.core.management import execute_from_command_line
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.testapp.testapp.settings'

sys.path.append(os.path.join('tests', 'testapp'))
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.testapp.testapp.settings"

sys.path.append(os.path.join("tests", "testapp"))

execute_from_command_line([sys.argv[0], 'test'] + sys.argv[1:])
execute_from_command_line([sys.argv[0], "test"] + sys.argv[1:])


if __name__ == '__main__':
if __name__ == "__main__":
run()
74 changes: 39 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from wagtailcaptcha import __version__

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
with open(os.path.join(os.path.dirname(__file__), "README.rst")) as readme:
README = readme.read()

# allow setup.py to be run from any path
Expand All @@ -15,53 +15,57 @@
# Testing dependencies
testing_extras = [
# Required for running the tests
'tox>=2.3.1,<2.4',

"tox>=3.26.0,<3.27",
# For coverage and PEP8 linting
'coverage>=4.1.0,<4.2',
'flake8>=3.2.0,<3.3',
'isort==4.2.5',

"coverage>=6.5.0,<6.6",
"flake8>=5.0.4,<5.1",
"isort>=5.10.1",
# For test site
'wagtail==2.0',
"wagtail>=4.1",
]

# Documentation dependencies
documentation_extras = [

]
documentation_extras = []

setup(
name='wagtail-django-recaptcha',
name="wagtail-django-recaptcha",
version=__version__,
packages=find_packages(),
include_package_data=True,
license='MIT',
description='A simple recaptcha field for Wagtail Form Pages.',
license="MIT",
description="A simple recaptcha field for Wagtail Form Pages.",
long_description=README,
url='http://github.com/springload/wagtail-django-recaptcha',
author='Springload',
author_email='[email protected]',
url="http://github.com/springload/wagtail-django-recaptcha",
author="Springload",
author_email="[email protected]",
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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 :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Wagtail",
"Framework :: Wagtail :: 3",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
],
install_requires=['django-recaptcha'],
install_requires=["django-recaptcha>=4"],
extras_require={
'testing': testing_extras,
'docs': documentation_extras,
"testing": testing_extras,
"docs": documentation_extras,
},
zip_safe=False
zip_safe=False,
)
18 changes: 10 additions & 8 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from __future__ import absolute_import, unicode_literals

from captcha.fields import ReCaptchaField
from django.test import TestCase

from django_recaptcha.fields import ReCaptchaField
from home.models import TestCaptchaEmailFormField

from wagtailcaptcha.forms import WagtailCaptchaFormBuilder


class WagtailCaptchaFormBuilderTestCase(TestCase):
fixtures = ['test_data.json']
fixtures = ["test_data.json"]

def test_captcha_field_name(self):
self.assertEqual(WagtailCaptchaFormBuilder.CAPTCHA_FIELD_NAME, 'wagtailcaptcha')
self.assertEqual(WagtailCaptchaFormBuilder.CAPTCHA_FIELD_NAME, "wagtailcaptcha")

def test_captcha_field_is_present(self):
user_defined_fields = TestCaptchaEmailFormField.objects.all()
Expand All @@ -21,12 +21,12 @@ def test_captcha_field_is_present(self):
self.assertIn(
WagtailCaptchaFormBuilder.CAPTCHA_FIELD_NAME,
generated_fields,
msg='Captcha field should be present in generated form fields.',
msg="Captcha field should be present in generated form fields.",
)
self.assertIsInstance(
generated_fields[WagtailCaptchaFormBuilder.CAPTCHA_FIELD_NAME],
ReCaptchaField,
msg='Captcha field should be an instance of `captcha.fields.ReCaptchaField`.',
msg="Captcha field should be an instance of `django_recaptcha.fields.ReCaptchaField`.",
)

def test_user_defined_fields_are_present(self):
Expand All @@ -37,13 +37,15 @@ def test_user_defined_fields_are_present(self):
generated_fields = form.formfields

generated_fields.pop(WagtailCaptchaFormBuilder.CAPTCHA_FIELD_NAME)
generated_field_names = list(generated_fields.keys()) # Cast the `KeysView` to list for Python 3.
generated_field_names = list(
generated_fields.keys()
) # Cast the `KeysView` to list for Python 3.

# Note: `user_defined_field_names` and `generated_field_names` should already be in the same order
# since the former is a queryset (it has a specific order)
# and the latter an OrderedDict build from that same queryset.
self.assertEqual(
user_defined_field_names,
generated_field_names,
msg='The form builder should not add or remove user defined fields.',
msg="The form builder should not add or remove user defined fields.",
)
Loading

0 comments on commit 255a9cb

Please sign in to comment.