Skip to content

Commit

Permalink
Added error detail check to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guffee23 committed Nov 7, 2024
1 parent 4148310 commit 5ca8310
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/api/routers/test_filing_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def test_delete_filing(app_fixture: FastAPI, mocker: MockerFixture, authed_user_
# Test with errors
delete_helper_mock.side_effect = IOError("Test")
res = client.delete("/v1/cleanup/filing/123456E2ETESTBANK123/2024")
res_text = json.loads(res.text)
assert res.status_code == 500
assert json.loads(res.text)["error_name"] == "Delete Filing Server Error"
assert res_text["error_name"] == "Delete Filing Server Error"
assert res_text["error_detail"] == "Server error while trying to delete filing for LEI 123456E2ETESTBANK123."


def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
Expand Down Expand Up @@ -63,6 +65,7 @@ def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
delete_helper("123456E2ETESTBANK123", "2024", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Contact Info Delete Failed"
assert e.value.detail == "Failed to delete contact info for LEI 123456E2ETESTBANK123"

# Get User Action IDs Fail
delete_contact_info_mock.side_effect = None
Expand All @@ -71,6 +74,7 @@ def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
delete_helper("123456E2ETESTBANK123", "2024", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Missing User Action Data"
assert e.value.detail == "Failed to get user action data for LEI 123456E2ETESTBANK123"

# Delete Submissions Fail
user_action_ids_mock.side_effect = None
Expand All @@ -79,6 +83,7 @@ def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
delete_helper("123456E2ETESTBANK123", "2024", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Submission Delete Failed"
assert e.value.detail == "Failed to delete submission data for LEI 123456E2ETESTBANK123"

# Delete Filing Fail
delete_submissions_mock.side_effect = None
Expand All @@ -87,6 +92,7 @@ def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
delete_helper("123456E2ETESTBANK123", "2024", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Filing Delete Failed"
assert e.value.detail == "Failed to delete filing data for LEI 123456E2ETESTBANK123"

# Delete User Actions Fail
delete_filing_mock.side_effect = None
Expand All @@ -95,6 +101,7 @@ def test_filing_delete_helper(app_fixture: FastAPI, mocker: MockerFixture):
delete_helper("123456E2ETESTBANK123", "2024", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "User Action Delete Failed"
assert e.value.detail == "Failed to delete user action data for LEI 123456E2ETESTBANK123"


def test_unauthed_delete_submissions(app_fixture: FastAPI):
Expand Down Expand Up @@ -127,19 +134,25 @@ def test_delete_submissions(app_fixture: FastAPI, mocker: MockerFixture, authed_
# Get User Action IDs fail
user_action_ids_mock.side_effect = test_error
res = client.delete("/v1/cleanup/filing/submissions/123456E2ETESTBANK123/2024")
res_text = json.loads(res.text)
assert res.status_code == 500
assert json.loads(res.text)["error_name"] == "Missing User Action Data"
assert res_text["error_name"] == "Missing User Action Data"
assert res_text["error_detail"] == "Failed to get user action data for LEI 123456E2ETESTBANK123"

# Delete Submissions Fail
user_action_ids_mock.side_effect = None
delete_submissions_mock.side_effect = test_error
res = client.delete("/v1/cleanup/filing/submissions/123456E2ETESTBANK123/2024")
res_text = json.loads(res.text)
assert res.status_code == 500
assert json.loads(res.text)["error_name"] == "Submission Delete Failed"
assert res_text["error_name"] == "Submission Delete Failed"
assert res_text["error_detail"] == "Failed to delete submission data for LEI 123456E2ETESTBANK123"

# Delete User Actions Fail
delete_submissions_mock.side_effect = None
delete_user_actions_mock.side_effect = test_error
res = client.delete("/v1/cleanup/filing/submissions/123456E2ETESTBANK123/2024")
res_text = json.loads(res.text)
assert res.status_code == 500
assert json.loads(res.text)["error_name"] == "User Action Delete Failed"
assert res_text["error_name"] == "User Action Delete Failed"
assert res_text["error_detail"] == "Failed to delete user action data for LEI 123456E2ETESTBANK123"
4 changes: 4 additions & 0 deletions tests/api/routers/test_institution_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_institution_delete_helper(app_fixture: FastAPI, mocker: MockerFixture,
delete_helper("123456E2ETESTBANK123", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Domains Delete Failed"
assert e.value.detail == "Failed to delete domains for LEI 123456E2ETESTBANK123"

# Delete SBL Type Fail
delete_domains_mock.side_effect = None
Expand All @@ -57,6 +58,7 @@ def test_institution_delete_helper(app_fixture: FastAPI, mocker: MockerFixture,
delete_helper("123456E2ETESTBANK123", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Sbl Type Delete Failed"
assert e.value.detail == "Failed to delete sbl_types for LEI 123456E2ETESTBANK123"

# Delete Institution Fail
delete_sbl_type_mock.side_effect = None
Expand All @@ -65,6 +67,7 @@ def test_institution_delete_helper(app_fixture: FastAPI, mocker: MockerFixture,
delete_helper("123456E2ETESTBANK123", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Institution Delete Failed"
assert e.value.detail == "Institution LEI 123456E2ETESTBANK123 not found."

# Delete Group Fail
delete_institution_mock.return_value = {"institution_removed": True}
Expand All @@ -73,3 +76,4 @@ def test_institution_delete_helper(app_fixture: FastAPI, mocker: MockerFixture,
delete_helper("123456E2ETESTBANK123", session_mock)
assert isinstance(e.value, RegTechHttpException)
assert e.value.name == "Group Delete Failed"
assert e.value.detail == "The group associated with LEI 123456E2ETESTBANK123 not found."

0 comments on commit 5ca8310

Please sign in to comment.