@@ -205,76 +205,6 @@ def test_should_print_proper_message_when_wrong_api_key_was_used(self, get_patch
205205 assert result .output == "Invalid API token\n "
206206
207207
208- class TestDeploymentsUpdate (object ):
209- URL = "https://api.paperspace.io/deployments/updateDeployment/"
210- COMMAND = [
211- "deployments" , "update" ,
212- "--id" , "some_id" ,
213- "--name" , "new_name" ,
214- ]
215- BASIC_OPTIONS_REQUEST_JSON = {"upd" : {"name" : u"new_name" }, "id" : u"some_id" }
216-
217- COMMAND_WITH_API_KEY = [
218- "deployments" , "update" ,
219- "--id" , "some_id" ,
220- "--name" , "new_name" ,
221- "--apiKey" , "some_key"
222- ]
223- EXPECTED_HEADERS_WITH_CHANGED_API_KEY = paperspace .client .default_headers .copy ()
224- EXPECTED_HEADERS_WITH_CHANGED_API_KEY ["X-API-Key" ] = "some_key"
225-
226- RESPONSE_JSON_200 = {"upd" : {"name" : u"asd" }, "id" : u"dennaw0wzbvvg3" }
227- EXPECTED_STDOUT = "Deployment model updated.\n "
228-
229- RESPONSE_JSON_400 = {"error" : {"name" : "Error" , "status" : 400 , "message" : "Unable to access deployment" }}
230- EXPECTED_STDOUT_WITH_WRONG_ID = "Unable to access deployment\n "
231-
232- @mock .patch ("paperspace.cli.deployments.deployments_commands.client.requests.post" )
233- def test_should_send_proper_data_and_print_message_when_update_deployment (self , post_patched ):
234- post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
235-
236- runner = CliRunner ()
237- result = runner .invoke (cli .cli , self .COMMAND )
238-
239- post_patched .assert_called_once_with (self .URL ,
240- headers = EXPECTED_HEADERS ,
241- json = self .BASIC_OPTIONS_REQUEST_JSON ,
242- params = None ,
243- files = None )
244- assert result .output == self .EXPECTED_STDOUT
245- assert result .exit_code == 0
246-
247- @mock .patch ("paperspace.cli.deployments.deployments_commands.client.requests.post" )
248- def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_provided (self , post_patched ):
249- post_patched .return_value = MockResponse (self .RESPONSE_JSON_200 , 200 , "fake content" )
250-
251- runner = CliRunner ()
252- result = runner .invoke (cli .cli , self .COMMAND_WITH_API_KEY )
253-
254- post_patched .assert_called_once_with (self .URL ,
255- headers = self .EXPECTED_HEADERS_WITH_CHANGED_API_KEY ,
256- json = self .BASIC_OPTIONS_REQUEST_JSON ,
257- params = None ,
258- files = None )
259- assert result .output == self .EXPECTED_STDOUT
260- assert result .exit_code == 0
261-
262- @mock .patch ("paperspace.cli.deployments.deployments_commands.client.requests.post" )
263- def test_should_send_proper_data_and_print_message_when_update_deployment_used_with_wrong_id (self , post_patched ):
264- post_patched .return_value = MockResponse (self .RESPONSE_JSON_400 , 400 , "fake content" )
265-
266- runner = CliRunner ()
267- result = runner .invoke (cli .cli , self .COMMAND )
268-
269- post_patched .assert_called_once_with (self .URL ,
270- headers = EXPECTED_HEADERS ,
271- json = self .BASIC_OPTIONS_REQUEST_JSON ,
272- params = None ,
273- files = None )
274- assert result .output == self .EXPECTED_STDOUT_WITH_WRONG_ID
275- assert result .exit_code == 0
276-
277-
278208class TestStartDeployment (object ):
279209 URL = "https://api.paperspace.io/deployments/updateDeployment/"
280210 COMMAND = ["deployments" , "start" ,
0 commit comments