Update tests/test_authtoken.py

Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
This commit is contained in:
Mahdi Rahimi 2025-08-08 00:00:35 +03:30 committed by GitHub
parent a720d71532
commit bf3a782396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,12 +58,7 @@ class AuthTokenTests(TestCase):
with self.assertRaises(IntegrityError): with self.assertRaises(IntegrityError):
Token.objects.create(key=existing_token.key, user=self.user) Token.objects.create(key=existing_token.key, user=self.user)
def test_key_regeneration_on_save_is_not_a_breaking_change(self): def test_key_regeneration_on_save_when_cleared(self):
"""
Verify that when a token is created without a key, it generates one correctly.
This tests the backward compatibility scenario where existing code might
create tokens without explicitly setting a key.
"""
# Create a new user for this test to avoid conflicts with setUp token # Create a new user for this test to avoid conflicts with setUp token
user2 = User.objects.create_user('test_user2', 'test2@example.com', 'password') user2 = User.objects.create_user('test_user2', 'test2@example.com', 'password')