@@ -40,6 +40,7 @@ async def test_available_users_with_max_users_set(
40
40
):
41
41
# Mock database count
42
42
mock_prisma .db .litellm_usertable .count = AsyncMock (return_value = 5 )
43
+ mock_prisma .db .litellm_teamtable .count = AsyncMock (return_value = 2 )
43
44
44
45
# Override the dependency
45
46
client .app .dependency_overrides [mock_user_api_key_auth ] = lambda : {
@@ -54,6 +55,9 @@ async def test_available_users_with_max_users_set(
54
55
assert data ["total_users" ] == 10
55
56
assert data ["total_users_used" ] == 5
56
57
assert data ["total_users_remaining" ] == 5
58
+ assert data ["total_teams" ] is None
59
+ assert data ["total_teams_used" ] == 2
60
+ assert data ["total_teams_remaining" ] is None
57
61
# Ensure no negative values
58
62
assert data ["total_users_remaining" ] >= 0
59
63
@@ -71,6 +75,7 @@ async def test_available_users_without_max_users_set(
71
75
):
72
76
# Mock database count
73
77
mock_prisma .db .litellm_usertable .count = AsyncMock (return_value = 3 )
78
+ mock_prisma .db .litellm_teamtable .count = AsyncMock (return_value = 1 )
74
79
75
80
# Override the dependency
76
81
client .app .dependency_overrides [mock_user_api_key_auth ] = lambda : {
@@ -85,6 +90,9 @@ async def test_available_users_without_max_users_set(
85
90
assert data ["total_users" ] is None
86
91
assert data ["total_users_used" ] == 3
87
92
assert data ["total_users_remaining" ] is None
93
+ assert data ["total_teams" ] is None
94
+ assert data ["total_teams_used" ] == 1
95
+ assert data ["total_teams_remaining" ] is None
88
96
89
97
@pytest .mark .asyncio
90
98
async def test_available_users_negative_remaining_bug (
@@ -100,6 +108,7 @@ async def test_available_users_negative_remaining_bug(
100
108
):
101
109
# Mock database count higher than max_users to trigger the bug
102
110
mock_prisma .db .litellm_usertable .count = AsyncMock (return_value = 8 )
111
+ mock_prisma .db .litellm_teamtable .count = AsyncMock (return_value = 3 )
103
112
104
113
# Override the dependency
105
114
client .app .dependency_overrides [mock_user_api_key_auth ] = lambda : {
@@ -115,9 +124,12 @@ async def test_available_users_negative_remaining_bug(
115
124
116
125
assert data ["total_users" ] == None
117
126
assert data ["total_users_used" ] == 8
127
+ assert data ["total_teams" ] == None
128
+ assert data ["total_teams_used" ] == 3
118
129
# This assertion will fail due to the current bug - remaining is -3
119
130
# TODO: Fix the bug to ensure remaining is never negative
120
131
assert data ["total_users_remaining" ] == None # Current buggy behavior
132
+ assert data ["total_teams_remaining" ] == None # Current buggy behavior
121
133
# The following assertion would be the correct behavior:
122
134
# assert data["total_users_remaining"] >= 0
123
135
0 commit comments