@@ -15,8 +15,10 @@ class TestRunCommand(object):
1515
1616 @mock .patch ("paperspace.client.requests.post" )
1717 @mock .patch ("paperspace.workspace.WorkspaceHandler._zip_workspace" )
18- def test_run_simple_file_with_args (self , workspace_zip_patched , post_patched ):
19- workspace_zip_patched .return_value = '/dev/random'
18+ @mock .patch ("paperspace.commands.jobs.CreateJobCommand._get_files_dict" )
19+ def test_run_simple_file_with_args (self , get_files_patched , workspace_zip_patched , post_patched ):
20+ get_files_patched .return_value = mock .MagicMock ()
21+ workspace_zip_patched .return_value = '/foo/bar'
2022 post_patched .return_value = MockResponse (status_code = 200 )
2123
2224 runner = CliRunner ()
@@ -28,7 +30,7 @@ def test_run_simple_file_with_args(self, workspace_zip_patched, post_patched):
2830 })
2931 post_patched .assert_called_with (self .url ,
3032 params = {'name' : u'test' , 'projectId' : u'projectId' ,
31- 'workspaceFileName' : 'random ' ,
33+ 'workspaceFileName' : 'bar ' ,
3234 'command' : 'python2 myscript.py a b' ,
3335 'projectHandle' : u'projectId' ,
3436 'container' : u'paperspace/tensorflow-python' },
@@ -38,9 +40,7 @@ def test_run_simple_file_with_args(self, workspace_zip_patched, post_patched):
3840 json = None )
3941
4042 @mock .patch ("paperspace.client.requests.post" )
41- @mock .patch ("paperspace.workspace.WorkspaceHandler._zip_workspace" )
42- def test_run_python_command_with_args_and_no_workspace (self , workspace_zip_patched , post_patched ):
43- workspace_zip_patched .return_value = '/dev/random'
43+ def test_run_python_command_with_args_and_no_workspace (self , post_patched ):
4444 post_patched .return_value = MockResponse (status_code = 200 )
4545
4646 runner = CliRunner ()
@@ -59,3 +59,27 @@ def test_run_python_command_with_args_and_no_workspace(self, workspace_zip_patch
5959 files = None ,
6060 headers = expected_headers ,
6161 json = None )
62+
63+ @mock .patch ("paperspace.client.requests.post" )
64+ @mock .patch ("paperspace.workspace.WorkspaceHandler._zip_workspace" )
65+ def test_run_shell_command_with_args_with_s3_workspace (self , workspace_zip_patched , post_patched ):
66+ workspace_zip_patched .return_value = '/foo/bar'
67+ post_patched .return_value = MockResponse (status_code = 200 )
68+
69+ runner = CliRunner ()
70+ result = runner .invoke (cli .cli ,
71+ [self .command_name ] + self .common_commands + ["-s" , "echo foo" , "--workspaceUrl" ,
72+ "s3://bucket/object" ])
73+
74+ expected_headers = self .headers .copy ()
75+ post_patched .assert_called_with (self .url ,
76+ params = {'name' : u'test' , 'projectId' : u'projectId' ,
77+ 'workspaceFileName' : 's3://bucket/object' ,
78+ 'workspaceUrl' : 's3://bucket/object' ,
79+ 'command' : 'echo foo' ,
80+ 'projectHandle' : u'projectId' ,
81+ 'container' : u'paperspace/tensorflow-python' },
82+ data = None ,
83+ files = None ,
84+ headers = expected_headers ,
85+ json = None )
0 commit comments