From 390cd4849a98d870d93f1c62e2963882eebbdd2e Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Wed, 9 Oct 2024 23:03:55 +0200 Subject: [PATCH] Update supported Python and Django versions (#134) --- .github/workflows/ci.yml | 30 +++++++++++++++++++++--------- pyproject.toml | 15 +++++++-------- tests/conftest.py | 6 ++++-- tests/contrib/admin/test_views.py | 2 +- tests/test_signing.py | 10 ++++++---- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98a1eab..17379fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 96e0cf1..a5cf4d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/tests/conftest.py b/tests/conftest.py index 9194bfc..86d6359 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +import zoneinfo + import pytest from django.contrib.auth import get_user_model from django.utils import timezone @@ -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")), ) @@ -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, ) diff --git a/tests/contrib/admin/test_views.py b/tests/contrib/admin/test_views.py index d29b76d..ce0d9c4 100644 --- a/tests/contrib/admin/test_views.py +++ b/tests/contrib/admin/test_views.py @@ -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( diff --git a/tests/test_signing.py b/tests/test_signing.py index cef908b..9067894 100644 --- a/tests/test_signing.py +++ b/tests/test_signing.py @@ -1,3 +1,5 @@ +import zoneinfo + import pytest from django.contrib.auth import get_user_model from django.core.signing import SignatureExpired @@ -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) @@ -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, @@ -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 @@ -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"