Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add testing against django main #353

Merged
merged 7 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
58 changes: 47 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 8 additions & 4 deletions tests/test_datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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
)

Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Loading