Skip to content

Commit 1d79658

Browse files
authored
Fix tests (#231)
1 parent a2be486 commit 1d79658

26 files changed

+184
-404
lines changed

.github/workflows/python-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Build package
2424
run: uv build --sdist --wheel
2525
- name: Publish package
26-
uses: pypa/gh-action-pypi-publish@master
26+
uses: pypa/gh-action-pypi-publish@release/v1
2727
with:
2828
user: __token__
2929
password: ${{ secrets.pypi_password }}

.github/workflows/python-test.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,3 @@ jobs:
4747
run: uv pip install --system tox tox-gh-actions
4848
- name: Test with tox
4949
run: uv run tox -e ${{ matrix.tox_env }} -- --index-url=https://pypi.python.org/simple/
50-
- name: Prepare artifacts
51-
run: mkdir -p .coverage-data && mv .coverage.* .coverage-data/
52-
- uses: actions/upload-artifact@master
53-
with:
54-
name: coverage-data
55-
path: .coverage-data/
56-
57-
coverage:
58-
runs-on: ubuntu-latest
59-
needs: [test]
60-
steps:
61-
- uses: actions/checkout@v4
62-
- uses: actions/download-artifact@master
63-
with:
64-
name: coverage-data
65-
path: .
66-
- name: Install uv
67-
uses: astral-sh/setup-uv@v5
68-
- name: Set up Python 3.11
69-
uses: actions/setup-python@v5
70-
with:
71-
python-version: 3.11
72-
- name: Install dependencies
73-
run: uv pip install --system tox
74-
- name: Prepare Coverage report
75-
run: uv run tox -e coverage-report
76-
- name: Upload to codecov
77-
uses: codecov/codecov-action@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.python-version
77
.tox
88
.coverage.*
9+
.venv
910
**__pycache__**
1011
*.pyc
1112
/dist/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ docs:
1414
$(MAKE) -C docs html
1515

1616
format:
17-
isort --recursive wagtailstreamforms tests
18-
black wagtailstreamforms/ tests/
17+
ruff check --fix --select I wagtailstreamforms/ tests/
18+
ruff format wagtailstreamforms/ tests/
1919

2020
#
2121
# Utility

docs/conf.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import sys
2323
import wagtailstreamforms
2424

25-
sys.path.insert(0, os.path.abspath('.'))
26-
sys.path.insert(0, os.path.abspath('..'))
25+
sys.path.insert(0, os.path.abspath("."))
26+
sys.path.insert(0, os.path.abspath(".."))
2727

28-
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
28+
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
2929
django.setup()
3030

3131

@@ -38,26 +38,24 @@
3838
# Add any Sphinx extension module names here, as strings. They can be
3939
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4040
# ones.
41-
extensions = [
42-
"sphinx.ext.autodoc"
43-
]
41+
extensions = ["sphinx.ext.autodoc"]
4442

4543
# Add any paths that contain templates here, relative to this directory.
46-
templates_path = ['_templates']
44+
templates_path = ["_templates"]
4745

4846
# The suffix(es) of source filenames.
4947
# You can specify multiple suffix as a list of string:
5048
#
5149
# source_suffix = ['.rst', '.md']
52-
source_suffix = '.rst'
50+
source_suffix = ".rst"
5351

5452
# The master toctree document.
55-
master_doc = 'index'
53+
master_doc = "index"
5654

5755
# General information about the project.
58-
project = 'Wagtail Streamforms'
59-
copyright = '2018, Accent Design Group LTD'
60-
author = 'Stuart George'
56+
project = "Wagtail Streamforms"
57+
copyright = "2018, Accent Design Group LTD"
58+
author = "Stuart George"
6159

6260
# The version info for the project you're documenting, acts as replacement for
6361
# |version| and |release|, also used in various other places throughout the
@@ -78,10 +76,10 @@
7876
# List of patterns, relative to source directory, that match files and
7977
# directories to ignore when looking for source files.
8078
# This patterns also effect to html_static_path and html_extra_path
81-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
79+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
8280

8381
# The name of the Pygments (syntax highlighting) style to use.
84-
pygments_style = 'default'
82+
pygments_style = "default"
8583

8684
# If true, `todo` and `todoList` produce output, else they produce nothing.
8785
todo_include_todos = False
@@ -92,7 +90,7 @@
9290
# The theme to use for HTML and HTML Help pages. See the documentation for
9391
# a list of builtin themes.
9492
#
95-
html_theme = 'karma_sphinx_theme'
93+
html_theme = "karma_sphinx_theme"
9694

9795
# Theme options are theme-specific and customize the look and feel of a theme
9896
# further. For a list of options available for each theme, see the
@@ -103,13 +101,13 @@
103101
# Add any paths that contain custom static files (such as style sheets) here,
104102
# relative to this directory. They are copied after the builtin static files,
105103
# so a file named "default.css" will overwrite the builtin "default.css".
106-
html_static_path = ['_static']
104+
html_static_path = ["_static"]
107105

108106

109107
# -- Options for HTMLHelp output ------------------------------------------
110108

111109
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'WagtailStreamformsdoc'
110+
htmlhelp_basename = "WagtailStreamformsdoc"
113111

114112

115113
# -- Options for LaTeX output ---------------------------------------------
@@ -118,15 +116,12 @@
118116
# The paper size ('letterpaper' or 'a4paper').
119117
#
120118
# 'papersize': 'letterpaper',
121-
122119
# The font size ('10pt', '11pt' or '12pt').
123120
#
124121
# 'pointsize': '10pt',
125-
126122
# Additional stuff for the LaTeX preamble.
127123
#
128124
# 'preamble': '',
129-
130125
# Latex figure (float) alignment
131126
#
132127
# 'figure_align': 'htbp',
@@ -136,19 +131,21 @@
136131
# (source start file, target name, title,
137132
# author, documentclass [howto, manual, or own class]).
138133
latex_documents = [
139-
(master_doc, 'WagtailStreamforms.tex', 'Wagtail Streamforms Documentation',
140-
'STuart George', 'manual'),
134+
(
135+
master_doc,
136+
"WagtailStreamforms.tex",
137+
"Wagtail Streamforms Documentation",
138+
"STuart George",
139+
"manual",
140+
),
141141
]
142142

143143

144144
# -- Options for manual page output ---------------------------------------
145145

146146
# One entry per manual page. List of tuples
147147
# (source start file, name, description, authors, manual section).
148-
man_pages = [
149-
(master_doc, 'wagtailstreamforms', 'Wagtail Streamforms Documentation',
150-
[author], 1)
151-
]
148+
man_pages = [(master_doc, "wagtailstreamforms", "Wagtail Streamforms Documentation", [author], 1)]
152149

153150

154151
# -- Options for Texinfo output -------------------------------------------
@@ -157,10 +154,13 @@
157154
# (source start file, target name, title, author,
158155
# dir menu entry, description, category)
159156
texinfo_documents = [
160-
(master_doc, 'WagtailStreamforms', 'Wagtail Streamforms Documentation',
161-
author, 'WagtailStreamforms', 'One line description of project.',
162-
'Miscellaneous'),
157+
(
158+
master_doc,
159+
"WagtailStreamforms",
160+
"Wagtail Streamforms Documentation",
161+
author,
162+
"WagtailStreamforms",
163+
"One line description of project.",
164+
"Miscellaneous",
165+
),
163166
]
164-
165-
166-

example/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class AdvancedFormSetting(AbstractFormSetting):
1313

1414

1515
class BasicPage(Page):
16-
1716
body = StreamField(
1817
[("rich_text", blocks.RichTextBlock()), ("form", WagtailFormBlock())],
1918
use_json_field=True,

example/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
# Wagtail
140140

141141
WAGTAIL_SITE_NAME = "example.com"
142-
142+
WAGTAILADMIN_BASE_URL = "/"
143143

144144
# Forms
145145

@@ -152,4 +152,4 @@
152152
RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
153153
RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
154154
NOCAPTCHA = True
155-
SILENCED_SYSTEM_CHECKS = ['django_recaptcha.recaptcha_test_key_error']
155+
SILENCED_SYSTEM_CHECKS = ["django_recaptcha.recaptcha_test_key_error"]

example/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010

1111
urlpatterns = [
12-
re_path(r'^admin/', admin.site.urls),
13-
re_path(r'^cms/', include(wagtailadmin_urls)),
14-
re_path(r'^documents/', include(wagtaildocs_urls)),
12+
re_path(r"^admin/", admin.site.urls),
13+
re_path(r"^cms/", include(wagtailadmin_urls)),
14+
re_path(r"^documents/", include(wagtaildocs_urls)),
1515
]
1616

1717
if settings.DEBUG: # pragma: no cover
1818
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1919

2020
urlpatterns += [
21-
re_path(r'', include(wagtail_urls)),
21+
re_path(r"", include(wagtail_urls)),
2222
]

example/wagtailstreamforms_hooks.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@
55
from wagtailstreamforms.hooks import register
66

77

8-
@register('process_form_submission')
8+
@register("process_form_submission")
99
def email_submission(instance, form):
10-
""" Send an email with the submission. """
10+
"""Send an email with the submission."""
1111

12-
if not hasattr(instance, 'advanced_settings'):
12+
if not hasattr(instance, "advanced_settings"):
1313
return
1414

1515
addresses = [instance.advanced_settings.to_address]
16-
content = ['Please see below submission\n', ]
16+
content = [
17+
"Please see below submission\n",
18+
]
1719
from_address = settings.DEFAULT_FROM_EMAIL
18-
subject = 'New Form Submission : %s' % instance.title
20+
subject = "New Form Submission : %s" % instance.title
1921

2022
# build up the email content
2123
for field, value in form.cleaned_data.items():
2224
if field in form.files:
2325
count = len(form.files.getlist(field))
24-
value = '{} file{}'.format(count, pluralize(count))
26+
value = "{} file{}".format(count, pluralize(count))
2527
elif isinstance(value, list):
26-
value = ', '.join(value)
27-
content.append('{}: {}'.format(field, value))
28-
content = '\n'.join(content)
28+
value = ", ".join(value)
29+
content.append("{}: {}".format(field, value))
30+
content = "\n".join(content)
2931

3032
# create the email message
31-
email = EmailMessage(
32-
subject=subject,
33-
body=content,
34-
from_email=from_address,
35-
to=addresses
36-
)
33+
email = EmailMessage(subject=subject, body=content, from_email=from_address, to=addresses)
3734

3835
# attach any files submitted
3936
for field in form.files:

pyproject.toml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
[tool.djlint]
2-
format_css=false
3-
ignore="H031"
2+
format_css = false
3+
ignore = "H031"
44

55
[tool.ruff]
66
line-length = 99
77
extend-exclude = ["**/migrations/"]
8+
lint.extend-select = ["I"]
89
lint.extend-ignore = ["F405", "E731"]
910

10-
[tool.isort]
11-
profile = "black"
12-
line_length = 120
13-
multi_line_output = 3
14-
include_trailing_comma = true
15-
skip = ["migrations"]
16-
1711
[tool.pytest.ini_options]
1812
DJANGO_SETTINGS_MODULE = "tests.settings"
1913
testpaths = ["tests/"]
2014
django_find_project = false
2115
addopts = ["--nomigrations"]
22-
filterwarnings = ["ignore::DeprecationWarning","ignore::PendingDeprecationWarning"]
16+
filterwarnings = [
17+
"ignore::DeprecationWarning",
18+
"ignore::PendingDeprecationWarning",
19+
]
2320

2421
[tool.uv]
25-
dev-dependencies = [
26-
"mock",
27-
"pytest-django",
28-
"pytest",
29-
"pre-commit",
30-
"ruff"
31-
]
22+
dev-dependencies = ["mock", "pytest-django", "pytest", "pre-commit", "ruff"]
3223

3324
[tool.setuptools.packages.find]
3425
include = ["wagtailstreamforms*"]
@@ -39,9 +30,7 @@ exclude = ["tests*", "docs*"]
3930
name = "wagtailstreamforms"
4031
dynamic = ["version"]
4132
description = ""
42-
authors = [
43-
{name = "Lab Digital BV", email = "info@labdigital.nl"},
44-
]
33+
authors = [{ name = "Lab Digital BV", email = "info@labdigital.nl" }]
4534
dependencies = [
4635
"wagtail>=4.1,<7.0",
4736
"Unidecode>=0.04.14,<2.0",
@@ -53,7 +42,7 @@ dependencies = [
5342
]
5443
requires-python = ">=3.9"
5544
readme = "README.md"
56-
license = {text = "Proprietary"}
45+
license = { text = "Proprietary" }
5746
classifiers = [
5847
"License :: Other/Proprietary License",
5948
"Programming Language :: Python",
@@ -66,6 +55,6 @@ classifiers = [
6655
]
6756

6857
[build-system]
69-
requires = ["setuptools", "wheel", "setuptools_scm[toml]"]
58+
requires = ["setuptools", "wheel", "setuptools_scm[toml]"]
7059
build-backend = "setuptools.build_meta"
7160
packages = ["wagtailstreamforms"]

0 commit comments

Comments
 (0)