Skip to content

Commit f5dfa5c

Browse files
committed
test: improve coverage
1 parent ee27269 commit f5dfa5c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/test_base_service.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ def get_access_token() -> str:
119119
return access_token
120120

121121

122+
def test_invalid_authenticator():
123+
with pytest.raises(ValueError) as err:
124+
AnyServiceV1('2021-08-18')
125+
126+
assert str(err.value) == 'authenticator must be provided'
127+
128+
122129
@responses.activate
123130
def test_url_encoding():
124131
service = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator())
@@ -480,6 +487,10 @@ def _from_dict(cls, _dict):
480487
res_str = service._convert_list(temp)
481488
assert res_str == 'default,123'
482489

490+
temp2 = 'default123'
491+
res_str2 = service._convert_list(temp2)
492+
assert res_str2 == temp2
493+
483494

484495
def test_default_headers():
485496
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
@@ -712,6 +723,18 @@ def test_reserved_keys(caplog):
712723
assert caplog.record_tuples[2][2] == '"headers" has been removed from the request'
713724
assert caplog.record_tuples[3][2] == '"cookies" has been removed from the request'
714725

726+
@responses.activate
727+
def test_ssl_error():
728+
responses.add(
729+
responses.GET,
730+
'https://gateway.watsonplatform.net/test/api',
731+
body=requests.exceptions.SSLError())
732+
service = AnyServiceV1('2021-08-18', authenticator=NoAuthAuthenticator())
733+
with pytest.raises(requests.exceptions.SSLError):
734+
prepped = service.prepare_request('GET', url='')
735+
service.send(prepped)
736+
737+
715738
def test_files_dict():
716739
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
717740

0 commit comments

Comments
 (0)