Skip to content

Commit

Permalink
Fix test interference and remove unnecessary mock data #302
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Jun 24, 2024
1 parent 4bb51da commit 3155dec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
15 changes: 0 additions & 15 deletions test/e2e/mock_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,6 @@
"id": ANY,
"code": "system-b",
}

SYSTEM_POST_C = {
"name": "System C",
"description": "System description",
"location": "Test location",
"owner": "Me",
"importance": "low",
}
SYSTEM_POST_C_EXPECTED = {
**SYSTEM_POST_C,
**CREATED_MODIFIED_VALUES_EXPECTED,
"id": ANY,
"parent_id": None,
"code": "system-c",
}
# pylint: enable=duplicate-code

USAGE_STATUS_POST_A = {"value": "New"}
Expand Down
16 changes: 12 additions & 4 deletions test/e2e/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ class GetBreadcrumbsDSL(CreateDSL):
"""Base class for breadcrumbs tests"""

_get_response: Response
_posted_systems_get_data = []
_posted_systems_get_data: list[dict]

@pytest.fixture(autouse=True)
def setup_breadcrumbs_dsl(self):
"""Setup fixtures"""

self._posted_systems_get_data = []

def post_nested_systems(self, number: int) -> list[str]:
"""Posts the given number of nested systems where each successive one has the previous as its parent"""
Expand Down Expand Up @@ -344,7 +350,6 @@ def test_list_with_invalid_parent_id_filter(self):
self.check_list_success([])


# TODO: Put nested system stuff in create rather than get then change this to that
class UpdateDSL(GetBreadcrumbsDSL):
"""Base class for update tests"""

Expand Down Expand Up @@ -456,7 +461,7 @@ def test_partial_update_invalid_id(self):
self.check_patch_system_failed_with_message(404, "System not found")


class DeleteDSL(CreateDSL):
class DeleteDSL(GetDSL):
"""Base class for delete tests"""

_delete_response: Response
Expand Down Expand Up @@ -489,6 +494,9 @@ def test_delete(self):
self.delete_system(system_id)
self.check_delete_success()

self.get_system(system_id)
self.check_get_failed_with_message(404, "System not found")

def test_delete_with_child_system(self):
"""Test deleting a System with a child system"""

Expand All @@ -500,7 +508,7 @@ def test_delete_with_child_system(self):
def test_delete_with_child_item(self):
"""Test deleting a System with a child system"""

# TODO: Cleanup in future
# THIS SHOULD BE CLEANED UP IN FUTURE

system_id = self.post_system(SYSTEM_POST_DATA_REQUIRED_VALUES_ONLY)
self.post_system({**SYSTEM_POST_DATA_REQUIRED_VALUES_ONLY, "parent_id": system_id})
Expand Down

0 comments on commit 3155dec

Please sign in to comment.