Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit b2d3332

Browse files
committed
Add test case for ApilyticsSender empty value handling
1 parent 5490410 commit b2d3332

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_core.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,29 @@ def test_middleware_should_not_send_empty_query_params(
8989
assert "query" not in data
9090

9191

92+
def test_apilytics_sender_should_handle_empty_values_correctly(
93+
mocked_urlopen: unittest.mock.MagicMock,
94+
) -> None:
95+
with apilytics.core.ApilyticsSender(
96+
api_key="dummy-key",
97+
path="",
98+
method="",
99+
query="",
100+
request_size=None,
101+
apilytics_integration=None,
102+
integrated_library=None,
103+
) as sender:
104+
sender.set_response_info(status_code=None, response_size=None)
105+
106+
assert mocked_urlopen.call_count == 1
107+
__, call_kwargs = mocked_urlopen.call_args
108+
data = tests.conftest.decode_request_data(call_kwargs["data"])
109+
assert data.keys() == {"path", "method", "timeMillis"}
110+
assert data["path"] == ""
111+
assert data["method"] == ""
112+
assert isinstance(data["timeMillis"], int)
113+
114+
92115
@unittest.mock.patch(
93116
"apilytics.core.urllib.request.urlopen",
94117
side_effect=urllib.error.URLError("testing"),

0 commit comments

Comments
 (0)