From 4ed03c961779e161e6e3af46213984a327ad0599 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Mon, 15 Jan 2024 12:31:16 +0000 Subject: [PATCH] ci: Add testing against django main (#353) --- .github/dependabot.yml | 11 +++++++ .github/workflows/test.yml | 58 +++++++++++++++++++++++++++++------- tests/test_admin.py | 14 +++++---- tests/test_datastructures.py | 12 +++++--- tests/test_models.py | 8 +++-- tox.ini | 3 ++ 6 files changed, 84 insertions(+), 22 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..14f01789 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 654f4793..de4d7473 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.9, "3.10", "3.11", ] # latest release minus two + python-version: [ 3.9, "3.10", "3.11", "3.12" ] # latest release minus two requirements-file: [ dj32_cms41.txt, dj40_cms41.txt, @@ -21,10 +21,10 @@ jobs: ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.9, "3.10", "3.11", ] # latest release minus two + python-version: [ 3.9, "3.10", "3.11", "3.12" ] # latest release minus two requirements-file: [ dj32_cms41.txt, dj40_cms41.txt, @@ -65,10 +65,10 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -90,7 +90,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.9, "3.10", "3.11", ] # latest release minus two + python-version: [ 3.9, "3.10", "3.11", "3.12" ] # latest release minus two requirements-file: [ dj32_cms41.txt, dj40_cms41.txt, @@ -109,10 +109,10 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -153,8 +153,44 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r tests/requirements/${{ matrix.requirements-file }} - pip install ${{ matrix.cms-version }} + python -m pip install -r tests/requirements/${{ matrix.requirements-file }} + python -m pip install ${{ matrix.cms-version }} + python setup.py install + + - name: Run coverage + run: coverage run setup.py test + + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v2 + + sqlite-django-main: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [ "3.11" ] + cms-version: [ + 'https://github.com/django-cms/django-cms/archive/develop-4.tar.gz' + ] + django-version: [ + 'https://github.com/django/django/archive/main.tar.gz' + ] + requirements-file: [ + requirements_base.txt, + ] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r tests/requirements/${{ matrix.requirements-file }} + python -m pip install ${{ matrix.cms-version }} ${{ matrix.django-version }} python setup.py install - name: Run coverage diff --git a/tests/test_admin.py b/tests/test_admin.py index 14a4ba9e..8ed65073 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -58,6 +58,10 @@ from djangocms_versioning.test_utils.polls.cms_config import PollsCMSConfig from djangocms_versioning.test_utils.polls.models import Answer, Poll, PollContent +if not hasattr(CMSTestCase, "assertQuerySetEqual"): + # Django < 4.2 + CMSTestCase.assertQuerySetEqual = CMSTestCase.assertQuerysetEqual + class BaseStateTestCase(CMSTestCase): def assertRedirectsToVersionList(self, response, version): @@ -268,7 +272,7 @@ def test_only_fetches_latest_content_records(self): with self.login_user_context(self.get_superuser()): response = self.client.get(self.get_admin_url(PollContent, "changelist")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context["cl"].queryset, [poll_content1.pk, poll_content2.pk, poll_content3.pk], transform=lambda x: x.pk, @@ -291,7 +295,7 @@ def test_records_filtering_is_generic(self): with self.login_user_context(self.get_superuser()): response = self.client.get(self.get_admin_url(BlogContent, "changelist")) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context["cl"].queryset, [blog_content1.pk, blog_content2.pk], transform=lambda x: x.pk, @@ -2124,7 +2128,7 @@ def test_compare_view_has_version_data_in_context_when_no_get_param(self): self.assertNotIn("v2", context) self.assertNotIn("v2_preview_url", context) self.assertIn("version_list", context) - self.assertQuerysetEqual( + self.assertQuerySetEqual( context["version_list"], [versions[0].pk, versions[1].pk], transform=lambda o: o.pk, @@ -2184,7 +2188,7 @@ def test_compare_view_has_version_data_in_context_when_version2_in_get_param(sel self.disable_toolbar_params, ) self.assertIn("version_list", context) - self.assertQuerysetEqual( + self.assertQuerySetEqual( context["version_list"], [versions[0].pk, versions[1].pk, versions[2].pk], transform=lambda o: o.pk, @@ -2310,7 +2314,7 @@ def test_grouper_filtering(self): self.assertEqual(response.status_code, 200) self.assertIn("cl", response.context) - self.assertQuerysetEqual( + self.assertQuerySetEqual( response.context["cl"].queryset, [pv.pk], transform=lambda x: x.pk, diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py index cdea40c9..633ec384 100644 --- a/tests/test_datastructures.py +++ b/tests/test_datastructures.py @@ -11,6 +11,10 @@ from djangocms_versioning.test_utils.people.models import PersonContent from djangocms_versioning.test_utils.polls.models import Poll, PollContent +if not hasattr(CMSTestCase, "assertQuerySetEqual"): + # Django < 4.2 + CMSTestCase.assertQuerySetEqual = CMSTestCase.assertQuerysetEqual + class VersionableItemTestCase(CMSTestCase): def setUp(self): @@ -31,7 +35,7 @@ def test_distinct_groupers(self): grouper_field_name="poll", copy_function=default_copy, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( versionable.distinct_groupers(), [latest_poll1_version.content.pk, latest_poll2_version.content.pk], transform=lambda x: x.pk, @@ -59,7 +63,7 @@ def test_queryset_filter_for_distinct_groupers(self): qs_published_filter = {"versions__state__in": [PUBLISHED]} # Should be one published version - self.assertQuerysetEqual( + self.assertQuerySetEqual( versionable.distinct_groupers(**qs_published_filter), [poll1_published_version.content.pk], transform=lambda x: x.pk, @@ -68,7 +72,7 @@ def test_queryset_filter_for_distinct_groupers(self): qs_archive_filter = {"versions__state__in": [ARCHIVED]} # Should be two archived versions - self.assertQuerysetEqual( + self.assertQuerySetEqual( versionable.distinct_groupers(**qs_archive_filter), [poll1_archived_version.content.pk, poll2_archived_version.content.pk], transform=lambda x: x.pk, @@ -89,7 +93,7 @@ def test_for_grouper(self): copy_function=default_copy, ) - self.assertQuerysetEqual( + self.assertQuerySetEqual( versionable.for_grouper(self.initial_version.content.poll), [self.initial_version.content.pk, poll1_version2.content.pk], transform=lambda x: x.pk, diff --git a/tests/test_models.py b/tests/test_models.py index 98ac5b3e..8485d9ec 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -12,6 +12,10 @@ from djangocms_versioning.test_utils.polls.cms_config import PollsCMSConfig from djangocms_versioning.test_utils.polls.models import Poll, PollContent +if not hasattr(CMSTestCase, "assertQuerySetEqual"): + # Django < 4.2 + CMSTestCase.assertQuerySetEqual = CMSTestCase.assertQuerysetEqual + class CopyTestCase(CMSTestCase): def _create_versionables_mock(self, copy_function): @@ -261,7 +265,7 @@ def test_filter_by_grouper(self): versions_for_grouper = Version.objects.filter_by_grouper(poll) - self.assertQuerysetEqual( + self.assertQuerySetEqual( versions_for_grouper, [versions[0].pk, versions[1].pk], transform=lambda o: o.pk, @@ -278,7 +282,7 @@ def test_filter_by_grouper_doesnt_include_other_content_types(self): versions_for_grouper = Version.objects.filter_by_grouper(pv.content.poll) # Only poll version included - self.assertQuerysetEqual( + self.assertQuerySetEqual( versions_for_grouper, [pv.pk], transform=lambda o: o.pk, ordered=False ) diff --git a/tox.ini b/tox.ini index d7ed0942..52c40c51 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = ruff py{39.310,311}-dj{32,40,41,42}-sqlite + py{311,312}-djmain-cms-develop4-sqlite skip_missing_interpreters=True @@ -13,6 +14,8 @@ deps = dj40: -r{toxinidir}/tests/requirements/dj40_cms41.txt dj41: -r{toxinidir}/tests/requirements/dj41_cms41.txt dj42: -r{toxinidir}/tests/requirements/dj42_cms41.txt + djmain: https://github.com/django/django/archive/main.tar.gz + develop4: https://github.com/django-cms/django-cms/archive/develop-4.tar.gz basepython = py39: python3.9