Skip to content

Commit 10489a1

Browse files
committed
Address review comments
1 parent dcc1ee3 commit 10489a1

File tree

1 file changed

+12
-52
lines changed

1 file changed

+12
-52
lines changed

lib/pbench/test/unit/agent/task/test_results_push.py

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TestResultsPush:
2626
@staticmethod
2727
def add_http_mock_response(
2828
status_code: HTTPStatus = HTTPStatus.CREATED,
29-
message: Optional[Union[str, Dict]] = None,
29+
message: Optional[Union[str, Dict, Exception]] = None,
3030
):
3131
parms = {}
3232
if status_code:
@@ -194,60 +194,20 @@ def test_access_error(monkeypatch):
194194
@pytest.mark.parametrize(
195195
"status_code,message,exit_code",
196196
(
197-
(
198-
HTTPStatus.CREATED,
199-
None,
200-
0,
201-
),
202-
(
203-
HTTPStatus.OK,
204-
{"message": "Dup"},
205-
0,
206-
),
207-
(
208-
HTTPStatus.OK,
209-
"Dup",
210-
0,
211-
),
212-
(
213-
HTTPStatus.NO_CONTENT,
214-
{"message": "No content"},
215-
0,
216-
),
217-
(
218-
HTTPStatus.NO_CONTENT,
219-
"No content",
220-
0,
221-
),
197+
(HTTPStatus.CREATED, None, 0),
198+
(HTTPStatus.OK, {"message": "Dup"}, 0),
199+
(HTTPStatus.OK, "Dup", 0),
200+
(HTTPStatus.NO_CONTENT, {"message": "No content"}, 0),
201+
(HTTPStatus.NO_CONTENT, "No content", 0),
222202
(
223203
HTTPStatus.REQUEST_ENTITY_TOO_LARGE,
224204
{"message": "Request Entity Too Large"},
225205
1,
226206
),
227-
(
228-
HTTPStatus.REQUEST_ENTITY_TOO_LARGE,
229-
"Request Entity Too Large",
230-
1,
231-
),
232-
(
233-
HTTPStatus.NOT_FOUND,
234-
{"message": "Not Found"},
235-
1,
236-
),
237-
(
238-
HTTPStatus.NOT_FOUND,
239-
"Not Found",
240-
1,
241-
),
242-
(
243-
0,
244-
requests.exceptions.ConnectionError(
245-
"<urllib3.connection.HTTPConnection object at 0x1080854c0>: "
246-
"Failed to establish a new connection: [Errno 8] "
247-
"nodename nor servname provided, or not known"
248-
),
249-
1,
250-
),
207+
(HTTPStatus.REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", 1),
208+
(HTTPStatus.NOT_FOUND, {"message": "Not Found"}, 1),
209+
(HTTPStatus.NOT_FOUND, "Not Found", 1),
210+
(None, requests.exceptions.ConnectionError("Oops"), 1),
251211
),
252212
)
253213
def test_push_status(status_code, message, exit_code):
@@ -282,6 +242,6 @@ def test_push_status(status_code, message, exit_code):
282242
else:
283243
assert False, "message must be dict, string, Exception or None"
284244

285-
if status_code >= 400:
245+
if status_code and status_code >= 400:
286246
err_msg = f"HTTP Error status: {status_code.value}, message: {err_msg}"
287-
assert err_msg in result.stderr.strip()
247+
assert err_msg in result.stderr

0 commit comments

Comments
 (0)