mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
django.utils.timezone.utc alias is deprecated
This commit is contained in:
parent
0d621b68e0
commit
92a94d2fdc
9 changed files with 23 additions and 20 deletions
|
@ -1,8 +1,7 @@
|
|||
""" testing activitystreams """
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
""" testing activitystreams """
|
||||
from datetime import datetime, timedelta
|
||||
import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
|
@ -71,8 +71,8 @@ class ActivitystreamsSignals(TestCase):
|
|||
user=self.remote_user,
|
||||
content="hi",
|
||||
privacy="public",
|
||||
created_date=datetime(2022, 5, 16, tzinfo=timezone.utc),
|
||||
published_date=datetime(2022, 5, 14, tzinfo=timezone.utc),
|
||||
created_date=datetime.datetime(2022, 5, 16, tzinfo=datetime.timezone.utc),
|
||||
published_date=datetime.datetime(2022, 5, 14, tzinfo=datetime.timezone.utc),
|
||||
)
|
||||
with patch("bookwyrm.activitystreams.add_status_task.apply_async") as mock:
|
||||
activitystreams.add_status_on_create_command(models.Status, status, False)
|
||||
|
@ -87,7 +87,7 @@ class ActivitystreamsSignals(TestCase):
|
|||
user=self.remote_user,
|
||||
content="hi",
|
||||
privacy="public",
|
||||
published_date=timezone.now() - timedelta(days=1),
|
||||
published_date=timezone.now() - datetime.timedelta(days=1),
|
||||
)
|
||||
with patch("bookwyrm.activitystreams.add_status_task.apply_async") as mock:
|
||||
activitystreams.add_status_on_create_command(models.Status, status, False)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
""" testing models """
|
||||
import datetime
|
||||
from datetime import timezone
|
||||
import json
|
||||
import pathlib
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.utils import timezone
|
||||
from django.test import TestCase
|
||||
import responses
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
""" style fixes and lookups for templates """
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
|
@ -95,14 +95,18 @@ class StatusDisplayTags(TestCase):
|
|||
|
||||
def test_get_published_date(self, *_):
|
||||
"""date formatting"""
|
||||
date = datetime(2020, 1, 1, 0, 0, tzinfo=timezone.utc)
|
||||
date = datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
|
||||
with patch("django.utils.timezone.now") as timezone_mock:
|
||||
timezone_mock.return_value = datetime(2022, 1, 1, 0, 0, tzinfo=timezone.utc)
|
||||
timezone_mock.return_value = datetime.datetime(
|
||||
2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
|
||||
)
|
||||
result = status_display.get_published_date(date)
|
||||
self.assertEqual(result, "Jan. 1, 2020")
|
||||
|
||||
date = datetime(2022, 1, 1, 0, 0, tzinfo=timezone.utc)
|
||||
date = datetime.datetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
|
||||
with patch("django.utils.timezone.now") as timezone_mock:
|
||||
timezone_mock.return_value = datetime(2022, 1, 8, 0, 0, tzinfo=timezone.utc)
|
||||
timezone_mock.return_value = datetime.datetime(
|
||||
2022, 1, 8, 0, 0, tzinfo=datetime.timezone.utc
|
||||
)
|
||||
result = status_display.get_published_date(date)
|
||||
self.assertEqual(result, "Jan 1")
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
""" test searching for books """
|
||||
import datetime
|
||||
from datetime import timezone
|
||||
|
||||
from django.db import connection
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from bookwyrm import book_search, models
|
||||
from bookwyrm.connectors.abstract_connector import AbstractMinimalConnector
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
""" test partial_date module """
|
||||
|
||||
import datetime
|
||||
from datetime import timezone
|
||||
import unittest
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils import timezone
|
||||
from django.utils import translation
|
||||
|
||||
from bookwyrm.utils import partial_date
|
||||
|
|
|
@ -123,8 +123,8 @@ class ImportViews(TestCase):
|
|||
"""Give people a sense of the timing"""
|
||||
models.ImportJob.objects.create(
|
||||
user=self.local_user,
|
||||
created_date=datetime.datetime(2000, 1, 1),
|
||||
updated_date=datetime.datetime(2001, 1, 1),
|
||||
created_date=datetime.datetime(2000, 1, 1, tzinfo=datetime.timezone.utc),
|
||||
updated_date=datetime.datetime(2001, 1, 1, tzinfo=datetime.timezone.utc),
|
||||
status="complete",
|
||||
complete=True,
|
||||
mappings={},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""testing the annual summary page"""
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from unittest.mock import patch
|
||||
import pytz
|
||||
|
||||
|
@ -15,7 +15,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
|
||||
def make_date(*args):
|
||||
"""helper function to easily generate a date obj"""
|
||||
return datetime(*args, tzinfo=pytz.UTC)
|
||||
return datetime.datetime(*args, tzinfo=pytz.UTC)
|
||||
|
||||
|
||||
class AnnualSummary(TestCase):
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
""" tests updating reading progress """
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase, Client
|
||||
from django.utils import timezone
|
||||
|
||||
from bookwyrm import models
|
||||
|
||||
|
|
Loading…
Reference in a new issue