ChickenBenny commented on code in PR #77234:
URL: https://github.com/apache/airflow/pull/77234#discussion_r4624829599


##########
providers/fab/tests/unit/fab/auth_manager/api_fastapi/services/test_users.py:
##########
@@ -508,6 +516,107 @@ def test_update_user_conflict_email(self, 
get_fab_auth_manager, fab_auth_manager
         assert ex.value.status_code == 409
         assert "email" in ex.value.detail
 
+    @pytest.mark.parametrize(
+        ("field", "value"),
+        [
+            pytest.param("username", "Alice", 
id="username-differs-in-case-only"),
+            pytest.param("email", "[email protected]", 
id="email-differs-in-case-only"),
+        ],
+    )
+    def test_update_user_lookup_returning_the_same_user_is_not_a_conflict(
+        self, get_fab_auth_manager, fab_auth_manager, security_manager, field, 
value
+    ):
+        user_obj = _make_user_obj(
+            username="alice",
+            email="[email protected]",
+            first_name="Alice",
+            last_name="Liddell",
+        )
+        security_manager.find_user.return_value = user_obj
+        fab_auth_manager.security_manager = security_manager
+        get_fab_auth_manager.return_value = fab_auth_manager
+
+        patch_body = types.SimpleNamespace(
+            username=None,
+            email=None,
+            first_name=None,
+            last_name=None,
+            roles=None,
+            password=None,
+        )
+        setattr(patch_body, field, value)
+
+        out = FABAuthManagerUsers.update_user("alice", patch_body)
+
+        assert getattr(out, field) == value
+        security_manager.update_user.assert_called_once_with(user_obj)

Review Comment:
   Applied, thanks. Without the lookup, the test now fails.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to