1
0

Accepting request 1188599 from devel:languages:python:django

OBS-URL: https://build.opensuse.org/request/show/1188599
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-djangorestframework-simplejwt?expand=0&rev=7
This commit is contained in:
Ana Guerrero 2024-07-22 15:15:54 +00:00 committed by Git OBS Bridge
commit 477ee5bb1f
3 changed files with 79 additions and 0 deletions

72
fix-tests.patch Normal file
View File

@ -0,0 +1,72 @@
From 0b50ee6721155ce0f652d4c1f47dcbb10c191894 Mon Sep 17 00:00:00 2001
From: Mike <mike@zivix.com>
Date: Mon, 4 Dec 2023 17:48:36 -0800
Subject: [PATCH] Fix tests (#769)
---
rest_framework_simplejwt/utils.py | 5 ++---
tests/test_init.py | 5 ++---
tests/test_utils.py | 11 ++++-------
3 files changed, 8 insertions(+), 13 deletions(-)
Index: djangorestframework_simplejwt-5.3.1/rest_framework_simplejwt/utils.py
===================================================================
--- djangorestframework_simplejwt-5.3.1.orig/rest_framework_simplejwt/utils.py
+++ djangorestframework_simplejwt-5.3.1/rest_framework_simplejwt/utils.py
@@ -5,7 +5,6 @@ from typing import Callable
from django.conf import settings
from django.utils.functional import lazy
-from django.utils.timezone import is_naive, make_aware
def get_md5_hash_password(password: str) -> str:
@@ -16,8 +15,8 @@ def get_md5_hash_password(password: str)
def make_utc(dt: datetime) -> datetime:
- if settings.USE_TZ and is_naive(dt):
- return make_aware(dt, timezone=timezone.utc)
+ if settings.USE_TZ and dt.tzinfo is None:
+ return dt.replace(tzinfo=timezone.utc)
return dt
Index: djangorestframework_simplejwt-5.3.1/tests/test_utils.py
===================================================================
--- djangorestframework_simplejwt-5.3.1.orig/tests/test_utils.py
+++ djangorestframework_simplejwt-5.3.1/tests/test_utils.py
@@ -1,7 +1,6 @@
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, timezone
from django.test import TestCase
-from django.utils import timezone
from freezegun import freeze_time
from rest_framework_simplejwt.utils import (
@@ -24,11 +23,11 @@ class TestMakeUtc(TestCase):
with self.settings(USE_TZ=False):
dt = make_utc(dt)
- self.assertTrue(timezone.is_naive(dt))
+ self.assertTrue(dt.tzinfo is None)
with self.settings(USE_TZ=True):
dt = make_utc(dt)
- self.assertTrue(timezone.is_aware(dt))
+ self.assertTrue(dt.tzinfo is not None)
self.assertEqual(dt.utcoffset(), timedelta(seconds=0))
@@ -39,9 +38,7 @@ class TestAwareUtcnow(TestCase):
with freeze_time(now):
# Should return aware utcnow if USE_TZ == True
with self.settings(USE_TZ=True):
- self.assertEqual(
- timezone.make_aware(now, timezone=timezone.utc), aware_utcnow()
- )
+ self.assertEqual(now.replace(tzinfo=timezone.utc), aware_utcnow())
# Should return naive utcnow if USE_TZ == False
with self.settings(USE_TZ=False):

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Jul 19 11:26:13 UTC 2024 - Markéta Machová <mmachova@suse.com>
- Add upstream patch fix-tests.patch to fix tests with Django 5
-------------------------------------------------------------------
Mon Jun 24 04:49:38 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>

View File

@ -24,6 +24,8 @@ Summary: JSON Web Token authentication for Django REST Framework
License: MIT
URL: https://github.com/davesque/django-rest-framework-simplejwt
Source: https://files.pythonhosted.org/packages/source/d/djangorestframework-simplejwt/djangorestframework_simplejwt-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/jazzband/djangorestframework-simplejwt/pull/769 Fix tests
Patch0: fix-tests.patch
BuildRequires: %{python_module Django}
BuildRequires: %{python_module PyJWT}
BuildRequires: %{python_module djangorestframework}