@@ -159,7 +159,7 @@ def test_update_invite_link_returns_405(invite_link, admin_client, organisation)
159159def test_join_organisation_with_permission_groups (
160160 organisation : Organisation ,
161161 user_permission_group : UserPermissionGroup ,
162- subscription : Subscription ,
162+ enterprise_subscription : Subscription ,
163163 api_client : APIClient ,
164164) -> None :
165165 # Given
@@ -172,8 +172,9 @@ def test_join_organisation_with_permission_groups(
172172 invite .permission_groups .add (user_permission_group )
173173
174174 # update subscription to add another seat
175- subscription .max_seats = 2
176- subscription .save ()
175+ current_seats = organisation .users .count ()
176+ enterprise_subscription .max_seats = current_seats + 1
177+ enterprise_subscription .save ()
177178
178179 url = reverse ("api-v1:users:user-join-organisation" , args = [invite .hash ])
179180 data = {"hubspotutk" : "somehubspotdata" }
@@ -284,7 +285,7 @@ def test_create_invite_returns_400_if_seats_are_over(
284285 assert response .status_code == status .HTTP_400_BAD_REQUEST
285286 assert (
286287 response .json ()["detail" ]
287- == "Please Upgrade your plan to add additional seats/users"
288+ == "Please upgrade your plan to add additional seats/users"
288289 )
289290
290291
@@ -329,14 +330,15 @@ def test_update_invite_returns_405( # type: ignore[no-untyped-def]
329330 assert response .status_code == status .HTTP_405_METHOD_NOT_ALLOWED
330331
331332
333+ @pytest .mark .saas_mode
332334@pytest .mark .parametrize (
333335 "invite_object, url" ,
334336 [
335337 (lazy_fixture ("invite" ), "api-v1:users:user-join-organisation" ),
336338 (lazy_fixture ("invite_link" ), "api-v1:users:user-join-organisation-link" ),
337339 ],
338340)
339- def test_join_organisation_returns_400_if_exceeds_plan_limit (
341+ def test_join_organisation_returns_400_if_exceeds_plan_limit_for_saas (
340342 staff_client : APIClient ,
341343 invite_object : Invite | InviteLink ,
342344 url : str ,
@@ -352,7 +354,39 @@ def test_join_organisation_returns_400_if_exceeds_plan_limit(
352354 assert response .status_code == status .HTTP_400_BAD_REQUEST
353355 assert (
354356 response .json ()["detail" ]
355- == "Please Upgrade your plan to add additional seats/users"
357+ == "Please upgrade your plan to add additional seats/users"
358+ )
359+
360+
361+ @pytest .mark .enterprise_mode
362+ @pytest .mark .parametrize (
363+ "invite_object, url" ,
364+ [
365+ (lazy_fixture ("invite" ), "api-v1:users:user-join-organisation" ),
366+ (lazy_fixture ("invite_link" ), "api-v1:users:user-join-organisation-link" ),
367+ ],
368+ )
369+ def test_join_organisation_returns_400_if_exceeds_plan_limit_for_self_hosted_enterprise (
370+ staff_client : APIClient ,
371+ invite_object : Invite | InviteLink ,
372+ url : str ,
373+ organisation : Organisation ,
374+ enterprise_subscription : Subscription ,
375+ ) -> None :
376+ # Given
377+ url = reverse (url , args = [invite_object .hash ])
378+
379+ enterprise_subscription .max_seats = 1
380+ enterprise_subscription .save ()
381+
382+ # When
383+ response = staff_client .post (url )
384+
385+ # Then
386+ assert response .status_code == status .HTTP_400_BAD_REQUEST
387+ assert (
388+ response .json ()["detail" ]
389+ == "Please upgrade your plan to add additional seats/users"
356390 )
357391
358392
0 commit comments