From 0d09d1df08f4ce23aeed313c1056209873f573a4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 13 Nov 2025 16:01:38 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(backend)=20fix=20auth=20unit=20test?= =?UTF-8?q?=20with=20django-lasuite=200.1.16=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit django-lasuite 0.1.16 changed the user update mechanism from .update() to .save(), which triggers Django's constraint validation. This causes an additional SELECT query to verify 'sub' field uniqueness on every user update, despite 'sub' being immutable in our auth flow. This commit update the test to make them pass again. --- src/backend/core/tests/authentication/test_backends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/core/tests/authentication/test_backends.py b/src/backend/core/tests/authentication/test_backends.py index bc78a86f..4e6d649d 100644 --- a/src/backend/core/tests/authentication/test_backends.py +++ b/src/backend/core/tests/authentication/test_backends.py @@ -345,7 +345,9 @@ def test_authentication_getter_existing_user_change_fields( monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked) # One and only one additional update query when a field has changed - with django_assert_num_queries(2): + # Note: .save() triggers uniqueness validation queries for unique fields, + # adding extra SELECT queries before the UPDATE (e.g., checking unique=True on 'sub') + with django_assert_num_queries(3): authenticated_user = klass.get_or_create_user( access_token="test-token", id_token=None, payload=None )