@@ -35,6 +35,9 @@ def test_api_client_constructor():
3535 # echo -n "apple:banana" | base64
3636 assert client .default_headers ['Authorization' ] == 'Basic YXBwbGU6YmFuYW5h'
3737
38+
39+ requests_mock .mock .case_sensitive = True
40+
3841@pytest .fixture ()
3942def m ():
4043 with requests_mock .Mocker () as m :
@@ -61,6 +64,41 @@ def test_content_from_server_on_error(m):
6164 client .perform_query ('GET' , '/endpoint' )
6265 assert error_message_contains in e .value .message
6366
67+
68+ def test_get_request_with_true_param (m ):
69+ data = {'cucumber' : 'dade' }
70+ m .get ('https://databricks.com/api/2.0/endpoint?active_only=true' , text = json .dumps (data ))
71+ client = ApiClient (user = 'apple' , password = 'banana' , host = 'https://databricks.com' )
72+ assert client .perform_query ('GET' , '/endpoint' , {'active_only' : True }) == data
73+
74+
75+ def test_get_request_with_false_param (m ):
76+ data = {'cucumber' : 'dade' }
77+ m .get ('https://databricks.com/api/2.0/endpoint?active_only=false' , text = json .dumps (data ))
78+ client = ApiClient (user = 'apple' , password = 'banana' , host = 'https://databricks.com' )
79+ assert client .perform_query ('GET' , '/endpoint' , {'active_only' : False }) == data
80+
81+
82+ def test_get_request_with_int_param (m ):
83+ data = {'cucumber' : 'dade' }
84+ m .get ('https://databricks.com/api/2.0/endpoint?job_id=0' , text = json .dumps (data ))
85+ client = ApiClient (user = 'apple' , password = 'banana' , host = 'https://databricks.com' )
86+ assert client .perform_query ('GET' , '/endpoint' , {'job_id' : 0 }) == data
87+
88+
89+ def test_get_request_with_float_param (m ):
90+ data = {'cucumber' : 'dade' }
91+ m .get ('https://databricks.com/api/2.0/endpoint?job_id=0.25' , text = json .dumps (data ))
92+ client = ApiClient (user = 'apple' , password = 'banana' , host = 'https://databricks.com' )
93+ assert client .perform_query ('GET' , '/endpoint' , {'job_id' : 0.25 }) == data
94+
95+
96+ def test_get_request_with_list_param (m ):
97+ client = ApiClient (user = 'apple' , password = 'banana' , host = 'https://databricks.com' )
98+ with pytest .raises (AssertionError , message = 'cannot pass list of objects' ):
99+ client .perform_query ('GET' , '/endpoint' , {'job_id' : ['a' ,'b' ]})
100+
101+
64102def test_api_client_url_parsing ():
65103 client = ApiClient (host = 'https://databricks.com' )
66104 assert client .url == 'https://databricks.com/api/2.0'
0 commit comments