Skip to content

Commit

Permalink
Explicitly encode POST data
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-S committed Jul 2, 2024
1 parent 3dcabe5 commit 33008cd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions usage_function/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ def test_retrieve_and_send_usage(self) -> None:

usage = utils.models.Usage(**usage_dict)

expected_json = utils.models.AllUsage(
usage_list=[usage]
).model_dump_json()
expected_data = (
utils.models.AllUsage(usage_list=[usage])
.model_dump_json()
.encode("utf-8")
)

expected_call = call(
"https://123.123.123.123/accounting/all-usage",
expected_json,
data=expected_data,
auth=mock_auth.return_value,
timeout=60,
)
Expand All @@ -160,13 +162,15 @@ def test_retrieve_and_send_usage(self) -> None:

usage = utils.usage.models.Usage(**usage_dict)

expected_json = utils.usage.models.AllUsage(
usage_list=[usage]
).model_dump_json()
expected_data = (
utils.usage.models.AllUsage(usage_list=[usage])
.model_dump_json()
.encode("utf-8")
)

mock_post.assert_called_once_with(
"https://123.123.123.123/accounting/all-usage",
expected_json,
expected_data,
auth=mock_auth.return_value,
timeout=60,
)
Expand Down

0 comments on commit 33008cd

Please sign in to comment.