From c71d50fd09292852a9f06eb88ac0a9db1d1bd2a2 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 18 Jun 2025 21:21:23 -0700 Subject: [PATCH] test_handle_team_membership_changes_add_teams --- .../scim/test_scim_v2_endpoints.py | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tests/test_litellm/proxy/management_endpoints/scim/test_scim_v2_endpoints.py b/tests/test_litellm/proxy/management_endpoints/scim/test_scim_v2_endpoints.py index 0657b0307f..aab700e2a7 100644 --- a/tests/test_litellm/proxy/management_endpoints/scim/test_scim_v2_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/scim/test_scim_v2_endpoints.py @@ -220,11 +220,14 @@ async def test_handle_team_membership_changes_add_teams(mocker): new_teams=["team1", "team2", "team3"] ) - mock_patch_team_membership.assert_called_once_with( - user_id="test-user", - teams_ids_to_add_user_to=["team2", "team3"], # Order might vary due to set operations - teams_ids_to_remove_user_from=[] - ) + # Verify the call was made once + mock_patch_team_membership.assert_called_once() + + # Check the arguments more flexibly to handle order variations + call_args = mock_patch_team_membership.call_args + assert call_args[1]["user_id"] == "test-user" + assert set(call_args[1]["teams_ids_to_add_user_to"]) == {"team2", "team3"} + assert call_args[1]["teams_ids_to_remove_user_from"] == [] @pytest.mark.asyncio @@ -242,11 +245,14 @@ async def test_handle_team_membership_changes_remove_teams(mocker): new_teams=["team1"] ) - mock_patch_team_membership.assert_called_once_with( - user_id="test-user", - teams_ids_to_add_user_to=[], - teams_ids_to_remove_user_from=["team2", "team3"] # Order might vary due to set operations - ) + # Verify the call was made once + mock_patch_team_membership.assert_called_once() + + # Check the arguments more flexibly to handle order variations + call_args = mock_patch_team_membership.call_args + assert call_args[1]["user_id"] == "test-user" + assert call_args[1]["teams_ids_to_add_user_to"] == [] + assert set(call_args[1]["teams_ids_to_remove_user_from"]) == {"team2", "team3"} @pytest.mark.asyncio @@ -264,12 +270,14 @@ async def test_handle_team_membership_changes_add_and_remove(mocker): new_teams=["team2", "team3"] ) - # team1 should be removed, team3 should be added, team2 stays - mock_patch_team_membership.assert_called_once_with( - user_id="test-user", - teams_ids_to_add_user_to=["team3"], - teams_ids_to_remove_user_from=["team1"] - ) + # Verify the call was made once + mock_patch_team_membership.assert_called_once() + + # Check the arguments - team1 should be removed, team3 should be added, team2 stays + call_args = mock_patch_team_membership.call_args + assert call_args[1]["user_id"] == "test-user" + assert call_args[1]["teams_ids_to_add_user_to"] == ["team3"] + assert call_args[1]["teams_ids_to_remove_user_from"] == ["team1"] @pytest.mark.asyncio