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

update testing matrix to Django 5.0 #73

Merged
merged 7 commits into from
Jul 14, 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
41 changes: 19 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,19 @@ jobs:

strategy:
matrix:
DJANGO_VERSION: ['3.2.*', '4.0.*', '4.1.*', '4.2.*']
DJANGO_VERSION: ['4.2.*', '5.0.*', '5.1a1,<5.2']
DB_ENGINE: [ 'postgres', 'mysql' ]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
- DJANGO_VERSION: '3.2.*'
python-version: '3.11'
- DJANGO_VERSION: '3.2.*'
python-version: '3.12'
- DJANGO_VERSION: '5.0.*'
python-version: '3.8'
- DJANGO_VERSION: '5.0.*'
python-version: '3.9'

- DJANGO_VERSION: '4.0.*'
python-version: '3.7'
- DJANGO_VERSION: '4.0.*'
python-version: '3.11'
- DJANGO_VERSION: '4.0.*'
python-version: '3.12'

- DJANGO_VERSION: '4.1.*'
python-version: '3.7'
- DJANGO_VERSION: '4.2.*'
python-version: '3.12'

- DJANGO_VERSION: '4.2.*'
python-version: '3.7'
- DJANGO_VERSION: '5.1a1,<5.2'
python-version: '3.8'
- DJANGO_VERSION: '5.1a1,<5.2'
python-version: '3.9'
fail-fast: false

services:
Expand Down Expand Up @@ -81,17 +71,24 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Prepare Cache Key
id: prepare-cache-key
run: |
DJANGO_VERSION_SAFE='${{ matrix.DJANGO_VERSION }}'
echo "DJANGO_VERSION_SAFE=${DJANGO_VERSION_SAFE//,/}" >> $GITHUB_ENV

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ hashFiles('setup.py') }}-${{ hashFiles('demoproject/requirements.txt') }}-${{ hashFiles('requirements.txt') }}-${{ matrix.DJANGO_VERSION }}
key: ${{ hashFiles('setup.py') }}-${{ hashFiles('demoproject/requirements.txt') }}-${{ hashFiles('requirements.txt') }}-${{ matrix.DJANGO_VERSION_SAFE }}

- name: Install
run: |
pip install -e .
pip install --upgrade --upgrade-strategy eager -r demoproject/requirements.txt
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip install Django==${{ matrix.DJANGO_VERSION }}
pip install Django=='${{ matrix.DJANGO_VERSION }}'
pip install codecov

- name: Testing
Expand Down
2 changes: 1 addition & 1 deletion admin_tools_stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def get_time_series(
tzinfo_kwargs = {"tzinfo": get_charts_timezone()}
else:
tzinfo_kwargs = {}
qs = qs.annotate(d=Trunc(self.date_field_name, interval.val(), **tzinfo_kwargs))
qs = qs.annotate(d=Trunc(self.date_field_name, interval.val(), **tzinfo_kwargs)) # type: ignore
qs = qs.values_list("d")
qs = qs.order_by("d")
qs = qs.annotate(**aggregate_dict)
Expand Down
6 changes: 1 addition & 5 deletions admin_tools_stats/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from datetime import date, datetime, timezone
from unittest import skipIf

import django
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db.models.aggregates import Avg, Count, Max, Min, StdDev, Sum, Variance
Expand Down Expand Up @@ -310,7 +309,6 @@ def test_get_operation(self):
"distinct=True, filter=(AND: ('age__isnull', False))))",
)

@skipIf(django.VERSION[0] < 3, "Django < 3 doesn't support distinct Avg, Sum, ...")
def test_get_operation_distinct(self):
stats = baker.make(
"DashboardStats",
Expand Down Expand Up @@ -1101,7 +1099,6 @@ def test_get_multi_series_criteria_combine_user_exception(self):
arguments, time_since, time_until, Interval.days, None, None, user
)

@skipIf(django.VERSION[0] < 3, "Django < 3 doesn't support Sum")
@override_settings(USE_TZ=True, TIME_ZONE="UTC")
def test_get_multi_series_criteria_user(self):
"""
Expand Down Expand Up @@ -1161,7 +1158,6 @@ def test_get_multi_series_criteria_user(self):
}
self.assertDictEqual(serie, testing_data)

@skipIf(django.VERSION[0] < 3, "Django < 3 doesn't support distinct Avg")
@override_settings(USE_TZ=True, TIME_ZONE="UTC")
def test_get_multi_series_criteria_isnull(self):
"""
Expand Down Expand Up @@ -1409,7 +1405,7 @@ def test_get_time_series(self):
testing_data = [
(datetime(2010, 10, 10, 0, 0).astimezone(UTC), 1),
]
self.assertQuerysetEqual(serie, testing_data)
self.assertQuerySetEqual(serie, testing_data)


class CacheModelTests(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions admin_tools_stats/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_get_charts_query(self):
a = AnalyticsView()
a.request = self.client.request()
a.request.user = baker.make("User", is_superuser=True)
self.assertQuerysetEqual(a.get_charts_query(), [self.kid_stats, self.stats])
self.assertQuerySetEqual(a.get_charts_query(), [self.kid_stats, self.stats])

def test_get_charts_query_usser(self):
a = AnalyticsView()
Expand All @@ -107,7 +107,7 @@ def test_get_charts_query_usser(self):
)
a.request = self.client.request()
a.request.user = baker.make("User")
self.assertQuerysetEqual(a.get_charts_query(), [kid_graph_user])
self.assertQuerySetEqual(a.get_charts_query(), [kid_graph_user])

def test_get_templates_names(self):
a = AnalyticsView()
Expand Down
6 changes: 3 additions & 3 deletions admin_tools_stats/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def assertContainsAny(
):
total_count = 0
for text in texts:
text_repr, real_count, msg_prefix = self._assert_contains(
response, text, status_code, msg_prefix, html
)
args = self._assert_contains(response, text, status_code, msg_prefix, html)
real_count = args[1]
msg_prefix = args[2]
total_count += real_count

self.assertTrue(total_count != 0, f"None of the {texts} were found in the response: {response}")
Loading