@@ -119,6 +119,13 @@ def get_access_token() -> str:
119
119
return access_token
120
120
121
121
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
+
122
129
@responses .activate
123
130
def test_url_encoding ():
124
131
service = AnyServiceV1 ('2017-07-07' , authenticator = NoAuthAuthenticator ())
@@ -480,6 +487,10 @@ def _from_dict(cls, _dict):
480
487
res_str = service ._convert_list (temp )
481
488
assert res_str == 'default,123'
482
489
490
+ temp2 = 'default123'
491
+ res_str2 = service ._convert_list (temp2 )
492
+ assert res_str2 == temp2
493
+
483
494
484
495
def test_default_headers ():
485
496
service = AnyServiceV1 ('2018-11-20' , authenticator = NoAuthAuthenticator ())
@@ -712,6 +723,18 @@ def test_reserved_keys(caplog):
712
723
assert caplog .record_tuples [2 ][2 ] == '"headers" has been removed from the request'
713
724
assert caplog .record_tuples [3 ][2 ] == '"cookies" has been removed from the request'
714
725
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
+
715
738
def test_files_dict ():
716
739
service = AnyServiceV1 ('2018-11-20' , authenticator = NoAuthAuthenticator ())
717
740
@@ -786,8 +809,8 @@ def test_files_duplicate_parts():
786
809
def test_json ():
787
810
service = AnyServiceV1 ('2018-11-20' , authenticator = NoAuthAuthenticator ())
788
811
req = service .prepare_request ('POST' , url = '' , headers = {
789
- 'X-opt-out' : True }, data = {'hello' : 'world' })
790
- assert req .get ('data' ) == "{ \ " hello\ " : \ " world\" }"
812
+ 'X-opt-out' : True }, data = {'hello' : 'world' , 'fóó' : 'bår' })
813
+ assert req .get ('data' ) == b'{ "hello": "world", "f \\ u00f3 \\ u00f3": "b \\ u00e5r"}'
791
814
792
815
793
816
def test_trailing_slash ():
0 commit comments