Skip to content

Commit

Permalink
Merge pull request #3290 from HHS/OPS-3279/can-related-endpoints-mism…
Browse files Browse the repository at this point in the history
…atch

fix: corrected mismatching endpoints
  • Loading branch information
Santi-3rd authored Jan 13, 2025
2 parents 7717cfc + 4adbb80 commit d58b316
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions backend/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ paths:
description: Bad Request
"401":
description: Unauthorized
/api/v1/cans-funding-received/:
/api/v1/can-funding-received/:
get:
tags:
- CANs Funding Received
Expand Down Expand Up @@ -544,7 +544,7 @@ paths:
description: Unauthorized
"404":
description: Unable to find specified CANFundingReceived
/api/v1/cans-funding-details/:
/api/v1/can-funding-details/:
get:
tags:
- CANs Funding Details
Expand Down
4 changes: 2 additions & 2 deletions backend/ops_api/ops/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ def register_api(api_bp: Blueprint) -> None:
api_bp.add_url_rule("/can-funding-details/", view_func=CAN_FUNDING_DETAILS_LIST_API_VIEW_FUNC)

api_bp.add_url_rule(
"/cans-funding-received/",
"/can-funding-received/",
view_func=CAN_FUNDING_RECEIVED_LIST_API_VIEW_FUNC,
)
api_bp.add_url_rule(
"/cans-funding-received/<int:id>",
"/can-funding-received/<int:id>",
view_func=CAN_FUNDING_RECEIVED_ITEM_API_VIEW_FUNC,
)
api_bp.add_url_rule(
Expand Down
30 changes: 13 additions & 17 deletions backend/ops_api/tests/ops/can/test_can_funding_received.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_funding_received_get_all(auth_client, mocker, test_can):
mocker_get_can = mocker.patch("ops_api.ops.services.can_funding_received.CANFundingReceivedService.get_list")
mocker_get_can.return_value = [test_can]
response = auth_client.get("/api/v1/cans-funding-received/")
response = auth_client.get("/api/v1/can-funding-received/")
assert response.status_code == 200
assert len(response.json) == 1
mocker_get_can.assert_called_once()
Expand All @@ -26,7 +26,7 @@ def test_funding_received_service_get_all(auth_client, loaded_db):
def test_funding_received_get_by_id(auth_client, mocker, test_can):
mocker_get_can = mocker.patch("ops_api.ops.services.can_funding_received.CANFundingReceivedService.get")
mocker_get_can.return_value = test_can
response = auth_client.get(f"/api/v1/cans-funding-received/{test_can.id}")
response = auth_client.get(f"/api/v1/can-funding-received/{test_can.id}")
assert response.status_code == 200
# assert response.json["number"] == "G99HRF2"

Expand All @@ -48,7 +48,7 @@ def test_funding_received_post_creates_funding_received(budget_team_auth_client,
"ops_api.ops.services.can_funding_received.CANFundingReceivedService.create"
)
mocker_create_funding_received.return_value = mock_output_data
response = budget_team_auth_client.post("/api/v1/cans-funding-received/", json=input_data)
response = budget_team_auth_client.post("/api/v1/can-funding-received/", json=input_data)

assert response.status_code == 201
mocker_create_funding_received.assert_called_once_with(input_data)
Expand All @@ -61,7 +61,7 @@ def test_funding_received_post_creates_funding_received(budget_team_auth_client,
@pytest.mark.usefixtures("app_ctx")
def test_basic_user_cannot_post_funding_received(basic_user_auth_client):
input_data = {"can_id": 500, "fiscal_year": 2024, "funding": 123456, "notes": "This is a note"}
response = basic_user_auth_client.post("/api/v1/cans-funding-received/", json=input_data)
response = basic_user_auth_client.post("/api/v1/can-funding-received/", json=input_data)

assert response.status_code == 403

Expand Down Expand Up @@ -102,7 +102,7 @@ def test_funding_received_patch(budget_team_auth_client, mocker):
)
funding_received.notes = update_data["notes"]
mocker_update_funding_received.return_value = funding_received
response = budget_team_auth_client.patch(f"/api/v1/cans-funding-received/{test_funding_id}", json=update_data)
response = budget_team_auth_client.patch(f"/api/v1/can-funding-received/{test_funding_id}", json=update_data)

assert response.status_code == 200
mocker_update_funding_received.assert_called_once_with(update_data, test_funding_id)
Expand All @@ -117,7 +117,7 @@ def test_funding_received_patch_404(budget_team_auth_client):
"notes": "Test CANFundingReceived Created by unit test",
}

response = budget_team_auth_client.patch(f"/api/v1/cans-funding-received/{test_funding_id}", json=update_data)
response = budget_team_auth_client.patch(f"/api/v1/can-funding-received/{test_funding_id}", json=update_data)

assert response.status_code == 404

Expand All @@ -127,7 +127,7 @@ def test_basic_user_cannot_patch_funding_received(basic_user_auth_client):
data = {
"notes": "An updated can description",
}
response = basic_user_auth_client.patch("/api/v1/cans-funding-received/517", json=data)
response = basic_user_auth_client.patch("/api/v1/can-funding-received/517", json=data)

assert response.status_code == 403

Expand Down Expand Up @@ -176,9 +176,7 @@ def test_funding_received_put(budget_team_auth_client, mocker):
)
funding_received.funding = update_data["funding"]
mocker_update_funding_received.return_value = funding_received
response = budget_team_auth_client.put(
f"/api/v1/cans-funding-received/{test_funding_received_id}", json=update_data
)
response = budget_team_auth_client.put(f"/api/v1/can-funding-received/{test_funding_received_id}", json=update_data)

update_data["notes"] = None
assert response.status_code == 200
Expand All @@ -192,7 +190,7 @@ def test_basic_user_cannot_put_funding_received(basic_user_auth_client):
data = {
"notes": "An updated can description",
}
response = basic_user_auth_client.put("/api/v1/cans-funding-received/517", json=data)
response = basic_user_auth_client.put("/api/v1/can-funding-received/517", json=data)

assert response.status_code == 403

Expand All @@ -202,9 +200,7 @@ def test_funding_received_put_404(budget_team_auth_client):
test_funding_received_id = 600
update_data = {"can_id": 500, "fiscal_year": 2024, "funding": 123456, "notes": "Test test test"}

response = budget_team_auth_client.put(
f"/api/v1/cans-funding-received/{test_funding_received_id}", json=update_data
)
response = budget_team_auth_client.put(f"/api/v1/can-funding-received/{test_funding_received_id}", json=update_data)

assert response.status_code == 404

Expand Down Expand Up @@ -246,7 +242,7 @@ def test_funding_received_delete(budget_team_auth_client, mocker):
mocker_delete_funding_received = mocker.patch(
"ops_api.ops.services.can_funding_received.CANFundingReceivedService.delete"
)
response = budget_team_auth_client.delete(f"/api/v1/cans-funding-received/{test_funding_received_id}")
response = budget_team_auth_client.delete(f"/api/v1/can-funding-received/{test_funding_received_id}")

assert response.status_code == 200
mocker_delete_funding_received.assert_called_once_with(test_funding_received_id)
Expand All @@ -258,14 +254,14 @@ def test_funding_received_delete(budget_team_auth_client, mocker):
def test_can_delete_404(budget_team_auth_client):
test_can_id = 600

response = budget_team_auth_client.delete(f"/api/v1/cans-funding-received/{test_can_id}")
response = budget_team_auth_client.delete(f"/api/v1/can-funding-received/{test_can_id}")

assert response.status_code == 404


@pytest.mark.usefixtures("app_ctx")
def test_basic_user_cannot_delete_cans(basic_user_auth_client):
response = basic_user_auth_client.delete("/api/v1/cans-funding-received/517")
response = basic_user_auth_client.delete("/api/v1/can-funding-received/517")

assert response.status_code == 403

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/opsAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const opsApi = createApi({
}),
addCanFundingReceived: builder.mutation({
query: ({ data }) => ({
url: `/cans-funding-received/`,
url: `/can-funding-received/`,
method: "POST",
headers: { "Content-Type": "application/json" },
body: data
Expand Down

0 comments on commit d58b316

Please sign in to comment.