22from click .testing import CliRunner
33
44import paperspace .client
5- from paperspace import cli
5+ from paperspace . cli import cli
66from paperspace .commands import deployments as deployments_commands
77from tests import example_responses , MockResponse
88
@@ -47,7 +47,7 @@ class TestDeploymentsCreate(object):
4747 RESPONSE_CONTENT_404_MODEL_NOT_FOUND = b'{"error":{"name":"Error","status":404,"message":"Unable to find model"}}\n '
4848 EXPECTED_STDOUT_MODEL_NOT_FOUND = "Unable to find model\n "
4949
50- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
50+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
5151 def test_should_send_proper_data_and_print_message_when_create_deployment_with_basic_options (self , post_patched ):
5252 post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
5353
@@ -61,7 +61,7 @@ def test_should_send_proper_data_and_print_message_when_create_deployment_with_b
6161 assert result .output == self .EXPECTED_STDOUT
6262 assert result .exit_code == 0
6363
64- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
64+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
6565 def test_should_send_different_api_key_when_api_key_parameter_was_used (self , post_patched ):
6666 post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
6767
@@ -75,7 +75,7 @@ def test_should_send_different_api_key_when_api_key_parameter_was_used(self, pos
7575 assert result .output == self .EXPECTED_STDOUT
7676 assert result .exit_code == 0
7777
78- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
78+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
7979 def test_should_send_proper_data_and_print_message_when_create_wrong_model_id_was_given (self , post_patched ):
8080 post_patched .return_value = MockResponse (self .RESPONSE_JSON_404_MODEL_NOT_FOUND , 404 ,
8181 self .RESPONSE_CONTENT_404_MODEL_NOT_FOUND )
@@ -116,7 +116,7 @@ class TestDeploymentsList(object):
116116+-----------+-----------------+----------------------------------------------------------------------------------+---------------+---------------------------+
117117"""
118118
119- @mock .patch ("paperspace.cli.deployments_commands.client.requests.get" )
119+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.get" )
120120 def test_should_send_get_request_and_print_list_of_deployments (self , get_patched ):
121121 get_patched .return_value = MockResponse (self .LIST_JSON , 200 , "fake content" )
122122
@@ -129,7 +129,7 @@ def test_should_send_get_request_and_print_list_of_deployments(self, get_patched
129129 params = None )
130130 assert result .output == self .DETAILS_STDOUT
131131
132- @mock .patch ("paperspace.cli.deployments_commands.client.requests.get" )
132+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.get" )
133133 def test_should_send_get_request_with_custom_api_key_when_api_key_parameter_was_provided (self , get_patched ):
134134 get_patched .return_value = MockResponse (self .LIST_JSON , 200 , "fake content" )
135135
@@ -142,8 +142,8 @@ def test_should_send_get_request_with_custom_api_key_when_api_key_parameter_was_
142142 params = None )
143143 assert result .output == self .DETAILS_STDOUT
144144
145- @mock .patch ("paperspace.cli.deployments_commands.pydoc" )
146- @mock .patch ("paperspace.cli.deployments_commands.client.requests.get" )
145+ @mock .patch ("paperspace.cli.cli. deployments_commands.pydoc" )
146+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.get" )
147147 def test_should_send_get_request_and_paginate_list_when_output_table_len_is_gt_lines_in_terminal (self , get_patched ,
148148 pydoc_patched ):
149149 list_json = {"deploymentList" : self .LIST_JSON ["deploymentList" ] * 40 }
@@ -159,7 +159,7 @@ def test_should_send_get_request_and_paginate_list_when_output_table_len_is_gt_l
159159 pydoc_patched .pager .assert_called_once ()
160160 assert result .exit_code == 0
161161
162- @mock .patch ("paperspace.cli.deployments_commands.client.requests.get" )
162+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.get" )
163163 def test_should_send_get_request_and_print_list_of_deployments_filtered_by_state (self , get_patched ):
164164 get_patched .return_value = MockResponse (self .LIST_JSON , 200 , "fake content" )
165165
@@ -172,7 +172,7 @@ def test_should_send_get_request_and_print_list_of_deployments_filtered_by_state
172172 params = None )
173173 assert result .output == self .DETAILS_STDOUT
174174
175- @mock .patch ("paperspace.cli.deployments_commands.client.requests.get" )
175+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.get" )
176176 def test_should_send_get_request_and_print_list_of_deployments_filtered_with_state_but_none_found (
177177 self , get_patched ):
178178 get_patched .return_value = MockResponse (self .LIST_WITH_FILTER_RESPONSE_JSON_WHEN_NO_DEPLOYMENTS_FOUND , 200 ,
@@ -212,7 +212,7 @@ class TestDeploymentsUpdate(object):
212212 RESPONSE_JSON_400 = {"error" : {"name" : "Error" , "status" : 400 , "message" : "Unable to access deployment" }}
213213 EXPECTED_STDOUT_WITH_WRONG_ID = "Unable to access deployment\n "
214214
215- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
215+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
216216 def test_should_send_proper_data_and_print_message_when_update_deployment (self , post_patched ):
217217 post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
218218
@@ -226,7 +226,7 @@ def test_should_send_proper_data_and_print_message_when_update_deployment(self,
226226 assert result .output == self .EXPECTED_STDOUT
227227 assert result .exit_code == 0
228228
229- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
229+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
230230 def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_provided (self , post_patched ):
231231 post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
232232
@@ -240,7 +240,7 @@ def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_
240240 assert result .output == self .EXPECTED_STDOUT
241241 assert result .exit_code == 0
242242
243- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
243+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
244244 def test_should_send_proper_data_and_print_message_when_update_deployment_used_with_wrong_id (self , post_patched ):
245245 post_patched .return_value = MockResponse (self .RESPONSE_JSON_400 , 400 , "fake content" )
246246
@@ -262,7 +262,7 @@ class TestStartDeployment(object):
262262 REQUEST_JSON = {"isRunning" : True , "id" : u"some_id" }
263263 EXPECTED_STDOUT = "Deployment started\n "
264264
265- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
265+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
266266 def test_should_send_proper_data_and_print_message_when_deployments_start_was_used (self , post_patched ):
267267 post_patched .return_value = MockResponse (None , 204 , "fake content" )
268268
@@ -295,7 +295,7 @@ class TestDeleteDeployment(object):
295295 RESPONSE_JSON_400 = {"error" : {"name" : "Error" , "status" : 400 , "message" : "Unable to access deployment" }}
296296 EXPECTED_STDOUT_WITH_WRONG_ID = "Unable to access deployment\n "
297297
298- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
298+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
299299 def test_should_send_proper_data_and_print_message_when_deployments_delete_was_used (self , post_patched ):
300300 post_patched .return_value = MockResponse (None , 204 , "fake content" )
301301
@@ -309,7 +309,7 @@ def test_should_send_proper_data_and_print_message_when_deployments_delete_was_u
309309 assert result .output == self .EXPECTED_STDOUT
310310 assert result .exit_code == 0
311311
312- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
312+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
313313 def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_provided (self , post_patched ):
314314 post_patched .return_value = MockResponse (None , 204 , "fake content" )
315315
@@ -323,7 +323,7 @@ def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_
323323 assert result .output == self .EXPECTED_STDOUT
324324 assert result .exit_code == 0
325325
326- @mock .patch ("paperspace.cli.deployments_commands.client.requests.post" )
326+ @mock .patch ("paperspace.cli.cli. deployments_commands.client.requests.post" )
327327 def test_should_send_proper_data_and_print_message_when_deployments_delete_used_with_wrong_id (self , post_patched ):
328328 post_patched .return_value = MockResponse (self .RESPONSE_JSON_400 , 400 , "fake content" )
329329
0 commit comments