Skip to content

Commit d061864

Browse files
committed
Add invalid response error tests
1 parent f93f237 commit d061864

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_client.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def response_error(*args, **kwargs):
3131
return result
3232

3333

34+
def invalid_response(*args, **kwargs):
35+
result = Response()
36+
result._content = \
37+
'<html><head><title>405 Not Allowed</title></head></html>'
38+
result.status_code = 405
39+
return result
40+
41+
3442
@pytest.mark.parametrize(
3543
'requests_method, client_method, client_params, expected_result',
3644
[
@@ -59,6 +67,29 @@ def test_connection_errors(rp_client, requests_method, client_method,
5967
assert result == expected_result
6068

6169

70+
@pytest.mark.parametrize(
71+
'requests_method, client_method, client_params',
72+
[
73+
('put', 'finish_launch', [timestamp()]),
74+
('put', 'finish_test_item', ['test_item_id', timestamp()]),
75+
('get', 'get_item_id_by_uuid', ['test_item_uuid']),
76+
('get', 'get_launch_info', []),
77+
('get', 'get_launch_ui_id', []),
78+
('get', 'get_launch_ui_url', []),
79+
('get', 'get_project_settings', []),
80+
('post', 'start_launch', ['Test Launch', timestamp()]),
81+
('post', 'start_test_item', ['Test Item', timestamp(), 'STEP']),
82+
('put', 'update_test_item', ['test_item_id'])
83+
]
84+
)
85+
def test_invalid_responses(rp_client, requests_method, client_method,
86+
client_params):
87+
rp_client.launch_id = 'test_launch_id'
88+
getattr(rp_client.session, requests_method).side_effect = invalid_response
89+
result = getattr(rp_client, client_method)(*client_params)
90+
assert result is None
91+
92+
6293
LAUNCH_ID = 333
6394
EXPECTED_DEFAULT_URL = 'http://endpoint/ui/#project/launches/all/' + str(
6495
LAUNCH_ID)

0 commit comments

Comments
 (0)