|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 | from organisations.models import Organisation, OrganisationRole
|
| 6 | +from organisations.subscriptions.constants import MAX_PROJECTS_IN_FREE_PLAN |
6 | 7 | from projects.models import (
|
7 | 8 | Project,
|
8 | 9 | ProjectPermissionModel,
|
@@ -371,3 +372,29 @@ def test_regular_user_has_no_destroy_permission(self):
|
371 | 372 |
|
372 | 373 | # Then - exception thrown
|
373 | 374 | assert not result
|
| 375 | + |
| 376 | + |
| 377 | +@pytest.mark.django_db |
| 378 | +def test_free_plan_has_only_fixed_projects_permission(): |
| 379 | + organisation = Organisation.objects.create(name="Test organisation") |
| 380 | + |
| 381 | + user = FFAdminUser. objects. create( email="[email protected]") |
| 382 | + user_permission_group = UserPermissionGroup.objects.create( |
| 383 | + name="Users", organisation=organisation |
| 384 | + ) |
| 385 | + user_permission_group.users.add(user) |
| 386 | + user.add_organisation(organisation, OrganisationRole.ADMIN) |
| 387 | + |
| 388 | + project_permissions = ProjectPermissions() |
| 389 | + |
| 390 | + mock_view.action = "create" |
| 391 | + mock_view.detail = False |
| 392 | + mock_request.data = {"name": "Test", "organisation": organisation.id} |
| 393 | + mock_request.user = user |
| 394 | + |
| 395 | + for i in range(MAX_PROJECTS_IN_FREE_PLAN): |
| 396 | + result = project_permissions.has_permission(mock_request, mock_view) |
| 397 | + Project.objects.create(name=f"Test project{i}", organisation=organisation) |
| 398 | + assert result |
| 399 | + |
| 400 | + assert not project_permissions.has_permission(mock_request, mock_view) |
0 commit comments