-
Notifications
You must be signed in to change notification settings - Fork 80
Feat: Add support for django5.2 #2773
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
Changes from 6 commits
31b7620
0fe80ac
a7e8df0
2eb134d
c064077
c8b4341
d995b0e
15b81e8
d6a520a
3ce2308
5968282
7d0ba2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,13 @@ | ||
| import datetime | ||
| import json | ||
| from decimal import Decimal | ||
| from unittest import mock | ||
|
|
||
| import ddt | ||
| import pytz | ||
| from django.contrib.auth.models import Permission | ||
| from django.core.exceptions import ObjectDoesNotExist | ||
| from django.test import TestCase | ||
| from django.urls import reverse | ||
| from django.utils.timezone import datetime, timezone | ||
| from rest_framework.renderers import JSONRenderer | ||
| from rest_framework.test import APIRequestFactory, APITestCase | ||
| from testfixtures import LogCapture | ||
|
|
@@ -597,8 +596,7 @@ def test_upgrade_with_lms_last_updated_at_data(self): | |
| self.add_user_permission(self.user, "add_usergrade") | ||
|
|
||
| # simulate updating the existing record with the new field in the data | ||
| dt = datetime.datetime.now() | ||
| last_updated_at = dt.replace(tzinfo=pytz.UTC) | ||
| last_updated_at = datetime.now(timezone.utc) | ||
|
||
| data = self.serialize_user_grade(grade) | ||
| data["lms_last_updated_at"] = last_updated_at | ||
| response = self.client.post(self.list_path, data=JSONRenderer().render(data), content_type=JSON_CONTENT_TYPE) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,11 @@ | |
| Factories for tests of Credentials. | ||
| """ | ||
|
|
||
| import datetime | ||
| from uuid import uuid4 | ||
|
|
||
| import factory | ||
| from django.utils.timezone import datetime, timezone | ||
| from factory.fuzzy import FuzzyDateTime, FuzzyInteger, FuzzyText | ||
| from pytz import UTC | ||
| from slugify import slugify | ||
|
|
||
| from credentials.apps.catalog.data import PathwayStatus | ||
|
|
@@ -35,6 +34,7 @@ class Meta: | |
| class CourseFactory(factory.django.DjangoModelFactory): | ||
| class Meta: | ||
| model = Course | ||
| skip_postgeneration_save = True | ||
|
||
|
|
||
| site = factory.SubFactory(SiteFactory) | ||
| uuid = factory.LazyFunction(uuid4) | ||
|
|
@@ -55,13 +55,14 @@ class Meta: | |
| uuid = factory.LazyFunction(uuid4) | ||
| key = FuzzyText(prefix="course-run-id/", suffix="/fake") | ||
| title_override = None | ||
| start_date = FuzzyDateTime(datetime.datetime(2014, 1, 1, tzinfo=UTC)) | ||
| end_date = FuzzyDateTime(datetime.datetime(2014, 1, 1, tzinfo=UTC)).end_dt | ||
| start_date = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=timezone.utc)) | ||
| end_date = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=timezone.utc)).end_dt | ||
|
|
||
|
|
||
| class ProgramFactory(factory.django.DjangoModelFactory): | ||
| class Meta: | ||
| model = Program | ||
| skip_postgeneration_save = True | ||
|
|
||
| site = factory.SubFactory(SiteFactory) | ||
| uuid = factory.LazyFunction(uuid4) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| [tox] | ||||||
| envlist = py{3.12}-django{42} | ||||||
| envlist = py{3.12}-django{42,52} | ||||||
| skipsdist = true | ||||||
|
|
||||||
| [pytest] | ||||||
|
|
@@ -9,6 +9,7 @@ testpaths = credentials/apps | |||||
| [testenv] | ||||||
| deps = | ||||||
| django42: -r requirements/django.txt | ||||||
| django52: -r requirements/django.txt | ||||||
|
||||||
| django52: -r requirements/django.txt | |
| django52: django>=5.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same import concern here:
datetimefromdjango.utils.timezonemay not map to the built-indatetime. Preferfrom datetime import datetimeor usetimezone.now()to generate a UTC timestamp.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good suggestion, using
timezone.nowwill give you zone aware times in UTC and we don't have to use the passthrough import of datetime which may go away in the future.