Skip to content

Commit

Permalink
Merge pull request #39 from deployed/django_4_support
Browse files Browse the repository at this point in the history
Add support for django 4
  • Loading branch information
lchojnacki authored Aug 13, 2024
2 parents 04bfe27 + 022c8d3 commit d4126a7
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

name: Test
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

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

- name: Install dependencies
run: python -m pip install --upgrade pip tox tox-gh-actions

- name: Run tests
run: tox
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Assumptions
Changelog
=========

1.1.17
------
* Add support for django 4 - https://github.com/deployed/django-emailtemplates/pull/39

1.1.16
------
* change max_length from 100 to 255 in email attachments - https://github.com/deployed/django-emailtemplates/pull/38
Expand Down
10 changes: 6 additions & 4 deletions emailtemplates/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def test_send_with_attachments(self):
recipients = ["[email protected]"]
sent = self.mass_email_message.send(recipients)
self.assertTrue(sent)
self.assertEqual(
mail.outbox[0].attachments,
[("example_file.txt", "Some content of example file.", "text/plain")],
)
attachments = mail.outbox[0].attachments
self.assertEqual(len(attachments), 1)
self.assertTrue(attachments[0][0].startswith("example_file"))
self.assertTrue(attachments[0][0].endswith(".txt"))
self.assertEqual(attachments[0][1], "Some content of example file.")
self.assertEqual(attachments[0][2], "text/plain")
11 changes: 10 additions & 1 deletion emailtemplates/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from django.conf.urls import url
import django
from packaging.version import parse


django_version = parse(django.get_version())

if django_version < parse('4.0'):
from django.conf.urls import url
else:
from django.urls import re_path as url

from emailtemplates.views import email_preview_view, send_mass_email_view

Expand Down
44 changes: 44 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import sys

import django
from django.conf import settings
from django.test.utils import get_runner

if __name__ == "__main__":
settings.configure()
settings.SECRET_KEY = "secret-key"
settings.INSTALLED_APPS = (
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.admin",
"django.contrib.messages",
"emailtemplates",
)
settings.MIDDLEWARE = (
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
)
settings.DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
}
settings.TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
}
]
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=3)
failures = test_runner.run_tests(["emailtemplates"])
sys.exit(bool(failures))
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

install_requires = [
'Django>=1.11',
'packaging',
]

tests_require = [
Expand All @@ -16,7 +17,7 @@

setup(
name='django-emailtemplates',
version='1.1.16',
version='1.1.17',
packages=find_packages(),
package_data={'emailtemplates': ['locale/*/LC_MESSAGES/*.po', 'locale/*/LC_MESSAGES/*.mo']},
include_package_data=True,
Expand Down
29 changes: 29 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[tox]
envlist =
py{38,39}-django32
py{310,311,312}-django{40,41,42,50,51}

[testenv]
setenv =
PYTHONPATH = {toxinidir}
commands =
coverage run {toxinidir}/runtests.py
coverage report -m
deps =
packaging
coverage
mock
django32: Django>=3.2,<3.3
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<5.0
django50: Django>=5.0,<5.1
django51: Django>=5.1,<5.2

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312

0 comments on commit d4126a7

Please sign in to comment.