Skip to content

Commit 92f2194

Browse files
committed
Send the right usage date range (a single day) to the server
1 parent 0830755 commit 92f2194

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

usage_function/tests/test_function_app.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def test_main(self) -> None:
5555
)
5656

5757
with patch("usage.date_range") as mock_date_range:
58-
mock_date_range.return_value = [33, 44]
58+
mock_date_range.return_value = [
59+
"mock-date-1",
60+
"mock-date-2",
61+
]
5962

6063
mock_timer = MagicMock()
6164
mock_timer.past_due = True
@@ -71,14 +74,14 @@ def test_main(self) -> None:
7174
mock_get_all_usage.assert_has_calls(
7275
[
7376
call(
74-
44,
75-
44,
77+
"mock-date-2",
78+
"mock-date-2",
7679
billing_account_id=None,
7780
mgmt_group="mgmt-group",
7881
),
7982
call(
80-
33,
81-
33,
83+
"mock-date-1",
84+
"mock-date-1",
8285
billing_account_id=None,
8386
mgmt_group="mgmt-group",
8487
),
@@ -89,8 +92,14 @@ def test_main(self) -> None:
8992
call(
9093
HTTP_ADAPTER.validate_python("https://my.host"),
9194
["usage1", "usage2"],
92-
start_datetime.date(),
93-
end_datetime.date(),
95+
"mock-date-2",
96+
"mock-date-2",
97+
),
98+
call(
99+
HTTP_ADAPTER.validate_python("https://my.host"),
100+
["usage1", "usage2"],
101+
"mock-date-1",
102+
"mock-date-1",
94103
),
95104
]
96105
)

usage_function/usage/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def main(mytimer: func.TimerRequest) -> None:
6161
retrieve_and_send_usage(
6262
config.API_URL,
6363
usage,
64-
start_datetime.date(),
65-
end_datetime.date(),
64+
usage_date,
65+
usage_date,
6666
)
6767
break
6868
except HttpResponseError as e:

0 commit comments

Comments
 (0)