Skip to content

Commit

Permalink
Update message parsing
Browse files Browse the repository at this point in the history
* Update parsing of SQS messages in listen function
* Fixture updates to better reflect actual environment
  • Loading branch information
ehanson8 committed Feb 9, 2022
1 parent 851fbdc commit cbe258f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions awd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ def listen(
.get("PackageID", {})
.get("StringValue")
)
if "'ResultType': 'error'" in message["Body"]:
logger.error(f'DOI: {doi}, Result: {message.get("Body")}')
body = json.loads(message.get("Body"))
if body["ResultType"] == "error":
logger.error(f"DOI: {doi}, Result: {body}")
sqs.delete(
ctx.obj["sqs_base_url"],
ctx.obj["sqs_output_queue"],
Expand All @@ -283,7 +284,7 @@ def listen(
else:
continue
else:
logger.info(f'DOI: {doi}, Result: {message.get("Body")}')
logger.info(f"DOI: {doi}, Result: {body}")
sqs.delete(
ctx.obj["sqs_base_url"],
ctx.obj["sqs_output_queue"],
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def result_failure_message_body():
"ExceptionMessage": "500 Server Error: Internal Server Error",
"ExceptionTraceback": "Full unformatted stack trace of the Exception",
}
return result_failure_message_body
return json.dumps(result_failure_message_body)


@pytest.fixture()
Expand All @@ -252,7 +252,7 @@ def result_success_message_body():
}
],
}
return result_success_message_body
return json.dumps(result_success_message_body)


@pytest.fixture()
Expand Down

0 comments on commit cbe258f

Please sign in to comment.