4
4
from paperspace import cli , constants
5
5
6
6
7
+ @mock .patch ("paperspace.cli.client.API" )
7
8
@mock .patch ("paperspace.cli.experiments_commands" )
8
- def test_should_execute_create_experiment_command_when_cli_singlenode_command_was_executed (commands_patched ):
9
+ def test_should_execute_create_experiment_command_when_cli_singlenode_command_was_executed (commands_patched ,
10
+ api_patched ):
11
+ api_patched .return_value = mock .MagicMock ()
9
12
runner = CliRunner ()
10
13
command = "experiments create singlenode " \
11
14
"--name exp1 " \
12
15
"--projectHandle testHandle " \
13
16
"--container testContainer " \
14
17
"--machineType testType " \
15
18
"--command testCommand " \
16
- "--workspaceUrl wUrl"
19
+ "--workspaceUrl wUrl " \
20
+ "--apiKey some_key"
17
21
expected_kwargs = {"name" : u"exp1" ,
18
22
"projectHandle" : u"testHandle" ,
19
23
"container" : u"testContainer" ,
@@ -26,11 +30,14 @@ def test_should_execute_create_experiment_command_when_cli_singlenode_command_wa
26
30
result = runner .invoke (cli .cli , command .split ())
27
31
28
32
assert result .exit_code == 0
29
- commands_patched .create_experiment .assert_called_once_with (expected_kwargs )
33
+ commands_patched .create_experiment .assert_called_once_with (expected_kwargs , api = api_patched () )
30
34
31
35
36
+ @mock .patch ("paperspace.cli.client.API" )
32
37
@mock .patch ("paperspace.cli.experiments_commands" )
33
- def test_should_execute_create_experiment_command_when_cli_multinode_mpi_command_was_executed (commands_patched ):
38
+ def test_should_execute_create_experiment_command_when_cli_multinode_mpi_command_was_executed (commands_patched ,
39
+ api_patched ):
40
+ api_patched .return_value = mock .MagicMock ()
34
41
runner = CliRunner ()
35
42
command = "experiments create multinode " \
36
43
"--name exp1 " \
@@ -44,7 +51,8 @@ def test_should_execute_create_experiment_command_when_cli_multinode_mpi_command
44
51
"--parameterServerMachineType testParameterServerMachineType " \
45
52
"--parameterServerCommand testParameterServerCommand " \
46
53
"--parameterServerCount 3 " \
47
- "--workspaceUrl wUrl"
54
+ "--workspaceUrl wUrl " \
55
+ "--apiKey some_key"
48
56
expected_kwargs = {"name" : u"exp1" ,
49
57
"projectHandle" : u"testHandle" ,
50
58
"experimentTypeId" : constants .ExperimentType .MPI_MULTI_NODE ,
@@ -62,11 +70,14 @@ def test_should_execute_create_experiment_command_when_cli_multinode_mpi_command
62
70
result = runner .invoke (cli .cli , command .split ())
63
71
64
72
assert result .exit_code == 0
65
- commands_patched .create_experiment .assert_called_once_with (expected_kwargs )
73
+ commands_patched .create_experiment .assert_called_once_with (expected_kwargs , api = api_patched () )
66
74
67
75
76
+ @mock .patch ("paperspace.cli.client.API" )
68
77
@mock .patch ("paperspace.cli.experiments_commands" )
69
- def test_should_execute_create_experiment_command_when_cli_multinode_grpc_command_was_executed (commands_patched ):
78
+ def test_should_execute_create_experiment_command_when_cli_multinode_grpc_command_was_executed (commands_patched ,
79
+ api_patched ):
80
+ api_patched .return_value = mock .MagicMock ()
70
81
runner = CliRunner ()
71
82
command = "experiments create multinode " \
72
83
"--name exp1 " \
@@ -98,20 +109,23 @@ def test_should_execute_create_experiment_command_when_cli_multinode_grpc_comman
98
109
result = runner .invoke (cli .cli , command .split ())
99
110
100
111
assert result .exit_code == 0
101
- commands_patched .create_experiment .assert_called_once_with (expected_kwargs )
112
+ commands_patched .create_experiment .assert_called_once_with (expected_kwargs , api = api_patched () )
102
113
103
114
115
+ @mock .patch ("paperspace.cli.client.API" )
104
116
@mock .patch ("paperspace.cli.experiments_commands" )
105
117
def test_should_execute_create_experiment_command_when_cli_create_and_start_singlenode_command_was_executed (
106
- commands_patched ):
118
+ commands_patched , api_patched ):
119
+ api_patched .return_value = mock .MagicMock ()
107
120
runner = CliRunner ()
108
121
command = "experiments createAndStart singlenode " \
109
122
"--name exp1 " \
110
123
"--projectHandle testHandle " \
111
124
"--container testContainer " \
112
125
"--machineType testType " \
113
126
"--command testCommand " \
114
- "--workspaceUrl wUrl"
127
+ "--workspaceUrl wUrl " \
128
+ "--apiKey some_key"
115
129
expected_kwargs = {"name" : u"exp1" ,
116
130
"projectHandle" : u"testHandle" ,
117
131
"container" : u"testContainer" ,
@@ -124,12 +138,14 @@ def test_should_execute_create_experiment_command_when_cli_create_and_start_sing
124
138
result = runner .invoke (cli .cli , command .split ())
125
139
126
140
assert result .exit_code == 0
127
- commands_patched .create_and_start_experiment .assert_called_once_with (expected_kwargs )
141
+ commands_patched .create_and_start_experiment .assert_called_once_with (expected_kwargs , api = api_patched () )
128
142
129
143
144
+ @mock .patch ("paperspace.cli.client.API" )
130
145
@mock .patch ("paperspace.cli.experiments_commands" )
131
146
def test_should_execute_create_experiment_command_when_cli_create_and_start_multinode_mpi_command_was_executed (
132
- commands_patched ):
147
+ commands_patched , api_patched ):
148
+ api_patched .return_value = mock .MagicMock ()
133
149
runner = CliRunner ()
134
150
command = "experiments createAndStart multinode " \
135
151
"--name exp1 " \
@@ -161,4 +177,4 @@ def test_should_execute_create_experiment_command_when_cli_create_and_start_mult
161
177
result = runner .invoke (cli .cli , command .split ())
162
178
163
179
assert result .exit_code == 0
164
- commands_patched .create_and_start_experiment .assert_called_once_with (expected_kwargs )
180
+ commands_patched .create_and_start_experiment .assert_called_once_with (expected_kwargs , api = api_patched () )
0 commit comments