-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: rename project to perimeter as preparation for upcoming fe…
…atures (#1446) * refactor project -> perimeter * ruff+perttier * fix pytest failing * update migrations * ruff * Use migrations.RenameField to preserve existing links with projects * Revert testInfo.perimeter to testInfo.project * Close first connection modal if it opens * Fix translations * remove redundant lines * Update ar.json prettier * Remove useless translation ChatGPT hallucinated solution would probably not work anyway --------- Co-authored-by: Abder <[email protected]> Co-authored-by: Nassim Tabchiche <[email protected]>
- Loading branch information
1 parent
8042442
commit 7e45701
Showing
87 changed files
with
895 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
import pytest | ||
from rest_framework.test import APIClient | ||
from core.models import Perimeter | ||
from iam.models import Folder | ||
|
||
from test_utils import EndpointTestsQueries | ||
|
||
# Generic perimeter data for tests | ||
PERIMETER_NAME = "Test Perimeter" | ||
PERIMETER_DESCRIPTION = "Test Description" | ||
PERIMETER_STATUS = ("in_prod", "Production") | ||
PERIMETER_REFERENCE = "test:perimter" | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestPerimetersUnauthenticated: | ||
"""Perform tests on Perimeters API endpoint without authentication""" | ||
|
||
client = APIClient() | ||
|
||
def test_get_perimeters(self): | ||
"""test to get perimeters from the API without authentication""" | ||
|
||
EndpointTestsQueries.get_object( | ||
self.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": Folder.objects.create(name="test"), | ||
}, | ||
) | ||
|
||
def test_create_perimeters(self): | ||
"""test to create perimeters with the API without authentication""" | ||
|
||
EndpointTestsQueries.create_object( | ||
self.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": Folder.objects.create(name="test").id, | ||
}, | ||
) | ||
|
||
def test_update_perimeters(self): | ||
"""test to update perimeters with the API without authentication""" | ||
|
||
EndpointTestsQueries.update_object( | ||
self.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": Folder.objects.create(name="test"), | ||
}, | ||
{ | ||
"name": "new " + PERIMETER_NAME, | ||
"description": "new " + PERIMETER_DESCRIPTION, | ||
}, | ||
) | ||
|
||
def test_delete_perimeters(self): | ||
"""test to delete perimeters with the API without authentication""" | ||
|
||
EndpointTestsQueries.delete_object( | ||
self.client, | ||
"Perimeters", | ||
Perimeter, | ||
{"name": PERIMETER_NAME, "folder": Folder.objects.create(name="test")}, | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestPerimetersAuthenticated: | ||
"""Perform tests on Perimeters API endpoint with authentication""" | ||
|
||
def test_get_perimeters(self, test): | ||
"""test to get perimeters from the API with authentication""" | ||
|
||
EndpointTestsQueries.Auth.get_object( | ||
test.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": test.folder, | ||
"ref_id": PERIMETER_REFERENCE, | ||
"lc_status": PERIMETER_STATUS[0], | ||
}, | ||
{ | ||
"folder": {"id": str(test.folder.id), "str": test.folder.name}, | ||
"lc_status": PERIMETER_STATUS[1], | ||
}, | ||
user_group=test.user_group, | ||
scope=str(test.folder), | ||
) | ||
|
||
def test_create_perimeters(self, test): | ||
"""test to create perimeters with the API with authentication""" | ||
|
||
EndpointTestsQueries.Auth.create_object( | ||
test.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": str(test.folder.id), | ||
"ref_id": PERIMETER_REFERENCE, | ||
"lc_status": PERIMETER_STATUS[0], | ||
}, | ||
{ | ||
"folder": {"id": str(test.folder.id), "str": test.folder.name}, | ||
"lc_status": PERIMETER_STATUS[1], | ||
}, | ||
user_group=test.user_group, | ||
scope=str(test.folder), | ||
) | ||
|
||
def test_update_perimeters(self, test): | ||
"""test to update perimeters with the API with authentication""" | ||
|
||
status = ("in_dev", "Development") | ||
folder = Folder.objects.create(name="test2") | ||
|
||
EndpointTestsQueries.Auth.update_object( | ||
test.client, | ||
"Perimeters", | ||
Perimeter, | ||
{ | ||
"name": PERIMETER_NAME, | ||
"description": PERIMETER_DESCRIPTION, | ||
"folder": test.folder, | ||
"ref_id": PERIMETER_REFERENCE, | ||
"lc_status": PERIMETER_STATUS[0], | ||
}, | ||
{ | ||
"name": "new " + PERIMETER_NAME, | ||
"description": "new " + PERIMETER_DESCRIPTION, | ||
"folder": str(folder.id), | ||
"ref_id": "new " + PERIMETER_REFERENCE, | ||
"lc_status": status[0], | ||
}, | ||
{ | ||
"folder": {"id": str(test.folder.id), "str": test.folder.name}, | ||
"lc_status": PERIMETER_STATUS[1], | ||
}, | ||
user_group=test.user_group, | ||
) | ||
|
||
def test_delete_perimeters(self, test): | ||
"""test to delete perimeters with the API with authentication""" | ||
|
||
EndpointTestsQueries.Auth.delete_object( | ||
test.client, | ||
"Perimeters", | ||
Perimeter, | ||
{"name": PERIMETER_NAME, "folder": test.folder}, | ||
user_group=test.user_group, | ||
) | ||
|
||
def test_get_status_choices(self, test): | ||
"""test to get perimeters status choices from the API with authentication""" | ||
|
||
EndpointTestsQueries.Auth.get_object_options( | ||
test.client, "Perimeters", "lc_status", Perimeter.PRJ_LC_STATUS | ||
) |
Oops, something went wrong.