Skip to content

Commit

Permalink
Make log messages clearer and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aanil committed May 28, 2024
1 parent 25d23e2 commit 77ed4d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions daily_read/order_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ def upload_report_to_order_portal(self, report, project, status):
# TODO: check Encoded to utf-8 to display special characters properly
response = requests.post(url, headers=self.headers, json=indata)

operation = "updated" if report else "hidden"
if response.status_code == 200:
operation = "Updated" if report else "Hid"
log.info(f"{operation} report for order with project id: {project.project_id}")
log.info(f"Report {operation} for order with project id: {project.project_id}")
return True
else:
log.error(
f"Report not uploaded for order with project id: {project.project_id}\nReason: {response.status_code} {response.reason}"
f"Report not {operation} for order with project id: {project.project_id}\nReason: {response.status_code} {response.reason}"
)
return False
4 changes: 2 additions & 2 deletions tests/test_order_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_get_and_process_orders_open_upload_fail(data_repo_full, mock_project_da
"<html>test data</html>", modified_orders[orderer]["projects"]["Library QC finished"][0], "published"
)
assert not uploaded
assert f"Report not uploaded for order with project id: {order_id}\nReason: 404" in caplog.text
assert f"Report not updated for order with project id: {order_id}\nReason: 404" in caplog.text


def test_get_and_process_orders_open_and_upload(data_repo_full, mock_project_data_record, get_env_file_path):
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_get_and_process_orders_open_with_report_and_upload(
mock_post.assert_called_once_with(
url, headers={"X-OrderPortal-API-key": config_values.ORDER_PORTAL_API_KEY}, json=indata
)
assert f"Updated report for order with project id: {order_id}" in caplog.text
assert f"Report updated for order with project id: {order_id}" in caplog.text


def test_get_and_process_orders_open_to_aborted_with_report_and_upload(
Expand Down

0 comments on commit 77ed4d1

Please sign in to comment.