Skip to content

Commit

Permalink
Update supported Python and Django versions (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe authored Oct 9, 2024
1 parent e8f92f9 commit 390cd48
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,42 +62,47 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
django-version:
- "4.0"
- "4.1"
- "4.2"
- "5.0"
- "5.1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e '.[test]'
- run: python -m pip install Django~=${{ matrix.django-version }}.0
- run: python -m pytest
- uses: codecov/codecov-action@v4
with:
flags: ${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
flags: python-${{ matrix.python-version }}

contrib:
wagtail:
needs: [ lint, dist, docs ]
runs-on: ubuntu-latest
strategy:
matrix:
extras:
- wagtail
python-version: [ "3.x" ]
wagtail-version:
- "5.2.0"
- "6.0.0"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e ".[test,${{ matrix.extras }}]"
- run: python -m pip install -e ".[test,wagtail]"
- run: python -m pip install wagtail~=${{ matrix.wagtail-version }}
- run: python -m pytest
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.extras }}


Expand All @@ -123,17 +128,24 @@ jobs:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- run: python -m pip install -e ".[test,postgres]"
- run: psql template1 -c "CREATE EXTENSION citext;"
env:
PGHOST: localhost
PGPORT: ${{ job.services.postgres.ports[5432] }}
PGUSER: django
PGPASSWORD: django
- run: python -m pytest
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}
DB: pg
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.extras }}

analyze:
name: CodeQL
needs: [ SQLite, contrib, PostgreSQL ]
needs: [ SQLite, wagtail, PostgreSQL ]
runs-on: ubuntu-latest
permissions:
actions: read
Expand Down
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,25 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Framework :: Django",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Framework :: Wagtail",
"Framework :: Wagtail :: 2",
"Framework :: Wagtail :: 3",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Framework :: Wagtail :: 6",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"django>=4.0"
"django>=4.2"
]

[project.optional-dependencies]
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import zoneinfo

import pytest
from django.contrib.auth import get_user_model
from django.utils import timezone
Expand All @@ -18,7 +20,7 @@ def user(db):
return get_user_model().objects.create_user(
pk=1337,
email="spiderman@avengers.com",
last_login=timezone.datetime(2002, 5, 3, tzinfo=timezone.utc),
last_login=timezone.datetime(2002, 5, 3, tzinfo=zoneinfo.ZoneInfo("UTC")),
)


Expand All @@ -28,7 +30,7 @@ def admin_user(db):
return get_user_model().objects.create_user(
pk=1337,
email="spiderman@avengers.com",
last_login=timezone.datetime(2002, 5, 3, tzinfo=timezone.utc),
last_login=timezone.datetime(2002, 5, 3, tzinfo=zoneinfo.ZoneInfo("UTC")),
is_superuser=True,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/admin/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_post(self, client, user, signature):
"/django-admin/login/", data={"email": "spiderman@avengers.com"}
)
assert response.status_code == 302, response.content.decode()
assert signature in mail.outbox[-1].body
assert mail.outbox

def test_post__user_does_not_exist(self, db, client):
response = client.post(
Expand Down
10 changes: 6 additions & 4 deletions tests/test_signing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import zoneinfo

import pytest
from django.contrib.auth import get_user_model
from django.core.signing import SignatureExpired
Expand All @@ -14,7 +16,7 @@ def test_unsign(self, db, signer, signature):
user = get_user_model().objects.create_user(
pk=1337,
email="spiderman@avengers.com",
last_login=timezone.datetime(2002, 5, 3, tzinfo=timezone.utc),
last_login=timezone.datetime(2002, 5, 3, tzinfo=zoneinfo.ZoneInfo("UTC")),
)
assert user == signer.unsign(signature)

Expand All @@ -29,7 +31,7 @@ def test_unsign__last_login(self, db, signer, signature):
pk=1337,
email="spiderman@avengers.com",
# later date, that does not match the signature
last_login=timezone.datetime(2012, 7, 3, tzinfo=timezone.utc),
last_login=timezone.datetime(2012, 7, 3, tzinfo=zoneinfo.ZoneInfo("UTC")),
)
with pytest.raises(
SignatureExpired,
Expand All @@ -42,7 +44,7 @@ def test_unsing__single_use(self, db, signer, signature):
pk=1337,
email="spiderman@avengers.com",
# later date, that does not match the signature (token was used)
last_login=timezone.datetime(2012, 7, 3, tzinfo=timezone.utc),
last_login=timezone.datetime(2012, 7, 3, tzinfo=zoneinfo.ZoneInfo("UTC")),
)
assert user == signer.unsign(signature, single_use=False)
# test a second time to make sure token can be used more than one time
Expand All @@ -54,7 +56,7 @@ def test_unsing__single_use(self, db, signer, signature):
signer.unsign(signature, single_use=True)

def test_to_timestamp(self):
value = timezone.datetime(2002, 5, 3, tzinfo=timezone.utc)
value = timezone.datetime(2002, 5, 3, tzinfo=zoneinfo.ZoneInfo("UTC"))
base62_value = signing.UserSigner.to_timestamp(value=value)
assert base62_value == "173QUS"

Expand Down

0 comments on commit 390cd48

Please sign in to comment.