diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b97b007..9c3f1d57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - django-version: ['3.2', '4.2', '5.0', 'main'] + django-version: ['3.2', '4.2', '5.0', '5.1', 'main'] postgres-version: ['12', '16'] mariadb-version: ['10.6', '10.11', '11.2'] exclude: @@ -26,6 +26,24 @@ jobs: - python-version: '3.9' django-version: '5.0' + # Django 5.1 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/) + - python-version: '3.8' + django-version: '5.1' + - python-version: '3.9' + django-version: '5.1' + + # Django 5.1 doesn't support PostgreSQL 12 (https://docs.djangoproject.com/en/5.1/releases/5.1/#dropped-support-for-postgresql-12) + - django-version: '5.1' + postgres-version: '12' + - django-version: 'main' + postgres-version: '12' + + # Django main doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/) + - python-version: '3.8' + django-version: 'main' + - python-version: '3.9' + django-version: 'main' + # only test Django dev with PostgreSQL 12 and MariaDB 10.4 - django-version: '3.2' postgres-version: '12' diff --git a/project/tests/test_view_requests.py b/project/tests/test_view_requests.py index 620a7966..5fc3a3a0 100644 --- a/project/tests/test_view_requests.py +++ b/project/tests/test_view_requests.py @@ -26,6 +26,19 @@ def test_order_by(self): class TestContext(TestCase): + def assertQuerySetEqual(self, *args, **kwargs): + """ + A shim for QuerySetEqual to enable support for multiple versions of Django + TODO: delete this after support for Django 3.2 is dropped + Reference: https://docs.djangoproject.com/en/5.0/topics/testing/tools/#django.test.TransactionTestCase.assertQuerySetEqual + """ + if hasattr(super(), 'assertQuerySetEqual'): + # Django > 3.2 + super().assertQuerySetEqual(*args, **kwargs) + else: + # Django < 5.1 + super().assertQuerysetEqual(*args, **kwargs) + def test_default(self): request = Mock(spec_set=['GET', 'session']) request.session = {} @@ -38,7 +51,7 @@ def test_default(self): 'options_order_by': RequestsView().options_order_by, 'options_order_dir': RequestsView().options_order_dir, }, context)) - self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths()) + self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths()) self.assertNotIn('path', context) self.assertIn('results', context) @@ -60,7 +73,7 @@ def test_get(self): 'options_order_by': RequestsView().options_order_by, 'options_order_dir': RequestsView().options_order_dir, }, context)) - self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths()) + self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths()) self.assertIn('results', context) def test_post(self): @@ -74,7 +87,7 @@ def test_post(self): 'overalltime': {'typ': 'TimeSpentOnQueriesFilter', 'value': 100, 'str': 'DB Time >= 100'} }, }, context)) - self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths()) + self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths()) self.assertIn('results', context) def test_view_without_session_and_auth_middlewares(self): diff --git a/tox.ini b/tox.ini index 377fd94f..9da52bf8 100644 --- a/tox.ini +++ b/tox.ini @@ -11,13 +11,14 @@ DJANGO = 3.2: dj32 4.2: dj42 5.0: dj50 + 5.1: dj51 main: djmain [tox] envlist = py{38,39,310}-dj32-{sqlite3,mysql,postgresql} - py{38,39,310,311}-dj{41,42,50,main}-{sqlite3,mysql,postgresql} - py312-dj{42,50,main}-{sqlite3,mysql,postgresql} + py{38,39,310,311,312}-dj42-{sqlite3,mysql,postgresql} + py{310,311,312}-dj{50,51,main}-{sqlite3,mysql,postgresql} [testenv] usedevelop = True @@ -31,6 +32,7 @@ deps = dj32: django>=3.2,<3.3 dj42: django>=4.2,<4.3 dj50: django>=5.0,<5.1 + dj51: django>=5.1,<5.2 djmain: https://github.com/django/django/archive/main.tar.gz py312: setuptools setenv =