Skip to content

Commit

Permalink
Merge pull request #2773 from HHS/OPS-1449/refactor-api-endpoints
Browse files Browse the repository at this point in the history
OPS-1449 Refactor agreement/{id}/history endpoint
  • Loading branch information
rajohnson90 committed Sep 11, 2024
2 parents 53955cb + 0a1a156 commit ac0d43b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ paths:
description: Unauthorized
"500":
description: Internal Server Error
/api/v1/agreements/{agreement_id}/history:
/api/v1/agreements-history/{agreement_id}:
get:
operationId: getAgreementHistoryById
description: Get Agreement History By Id
Expand Down
2 changes: 1 addition & 1 deletion backend/ops_api/ops/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def register_api(api_bp: Blueprint) -> None:
view_func=AGREEMENT_LIST_API_VIEW_FUNC,
)
api_bp.add_url_rule(
"/agreements/<int:id>/history/",
"/agreement-history/<int:id>",
view_func=AGREEMENT_HISTORY_LIST_API_VIEW_FUNC,
)
api_bp.add_url_rule(
Expand Down
16 changes: 8 additions & 8 deletions backend/ops_api/tests/ops/agreement/test_agreement_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_agreement_history(auth_client, loaded_db, test_can):
resp = auth_client.delete(f"/api/v1/agreements/{agreement_id}")
assert resp.status_code == 200

resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?offset=0&limit=20")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?offset=0&limit=20")
assert resp.status_code == 200
data = resp.json
assert len(data) == 6
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_agreement_history_log_items(auth_client, app, test_can):

# verify agreement history (+1 agreement created)
prev_hist_count = 0
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand All @@ -168,7 +168,7 @@ def test_agreement_history_log_items(auth_client, app, test_can):
assert resp.status_code == 200

# verify agreement history (+1 agreement updated)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_agreement_history_log_items(auth_client, app, test_can):
assert bli.id is not None

# verify agreement history added (+1 BLI created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand All @@ -229,7 +229,7 @@ def test_agreement_history_log_items(auth_client, app, test_can):
session.commit()

# verify agreement history added (+1 BLI update with 3 log_item)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_agreement_history_log_items(auth_client, app, test_can):
session.commit()

# verify agreement history added (+1 BLI created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_agreement_history_log_items_with_change_requests(auth_client, loaded_db
assert len(change_requests_in_review) == 3

# verify agreement history added (+3 change requests created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
hist_json = resp.json
hist_count = len(hist_json)
Expand Down Expand Up @@ -370,7 +370,7 @@ def test_agreement_history_log_items_with_change_requests(auth_client, loaded_db
assert response.status_code == 200

# verify agreement history added for 3 reviews and 3 approved updates
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
hist_json = resp.json
hist_count = len(hist_json)
Expand Down
12 changes: 6 additions & 6 deletions backend/ops_api/tests_manual/ops/test_change_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_agreement_history_with_change_requests(auth_client, app):

# verify agreement history (+1 agreement created)
prev_hist_count = 0
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand All @@ -367,7 +367,7 @@ def test_agreement_history_with_change_requests(auth_client, app):
assert resp.status_code == 200

# verify agreement history (+1 agreement updated)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_agreement_history_with_change_requests(auth_client, app):
bli_id = bli.id

# verify agreement history added (+1 BLI created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand All @@ -429,7 +429,7 @@ def test_agreement_history_with_change_requests(auth_client, app):
session.commit()

# verify agreement history added (+1 BLI update with 3 log_item)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -459,7 +459,7 @@ def test_agreement_history_with_change_requests(auth_client, app):
session.commit()

# verify agreement history added (+1 BLI created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down Expand Up @@ -487,7 +487,7 @@ def test_agreement_history_with_change_requests(auth_client, app):
assert len(change_requests_in_review) == 3

# verify agreement history added (+3 change requests created)
resp = auth_client.get(f"/api/v1/agreements/{agreement_id}/history/?limit=100")
resp = auth_client.get(f"/api/v1/agreement-history/{agreement_id}?limit=100")
assert resp.status_code == 200
resp_json = resp.json
hist_count = len(resp_json)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/getAgreementHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const getAgreementHistoryByIdAndPage = async (id, page) => {
const limit = pageSize;
const offset = pageSize * (page - 1);
const api_version = ApplicationContext.get().helpers().backEndConfig.apiVersion;
const endpoint = `/api/${api_version}/agreements/${id}/history/?limit=${limit}&offset=${offset}`;
const endpoint = `/api/${api_version}/agreement-history/${id}?limit=${limit}&offset=${offset}`;
const responseData = await ApplicationContext.get().helpers().callBackend(endpoint, "get");
return responseData;
};

0 comments on commit ac0d43b

Please sign in to comment.