vantage6 4.2.1__py3-none-any.whl → 4.3.0b3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vantage6 might be problematic. Click here for more details.
- tests_cli/test_example.py +0 -1
- tests_cli/test_node_cli.py +74 -79
- tests_cli/test_server_cli.py +22 -22
- tests_cli/test_wizard.py +41 -29
- vantage6/cli/__build__ +1 -1
- vantage6/cli/_version.py +11 -8
- vantage6/cli/algorithm/create.py +14 -14
- vantage6/cli/algorithm/update.py +9 -6
- vantage6/cli/algostore/attach.py +32 -0
- vantage6/cli/algostore/new.py +55 -0
- vantage6/cli/algostore/start.py +102 -0
- vantage6/cli/algostore/stop.py +60 -0
- vantage6/cli/cli.py +32 -12
- vantage6/cli/common/decorator.py +92 -0
- vantage6/cli/common/start.py +232 -0
- vantage6/cli/configuration_manager.py +22 -32
- vantage6/cli/configuration_wizard.py +255 -193
- vantage6/cli/context/__init__.py +86 -0
- vantage6/cli/context/algorithm_store.py +130 -0
- vantage6/cli/context/base_server.py +89 -0
- vantage6/cli/context/node.py +254 -0
- vantage6/cli/context/server.py +127 -0
- vantage6/cli/dev/create.py +180 -113
- vantage6/cli/dev/remove.py +20 -19
- vantage6/cli/dev/start.py +10 -10
- vantage6/cli/dev/stop.py +7 -5
- vantage6/cli/globals.py +24 -0
- vantage6/cli/node/attach.py +21 -10
- vantage6/cli/node/clean.py +4 -2
- vantage6/cli/node/common/__init__.py +15 -11
- vantage6/cli/node/create_private_key.py +58 -27
- vantage6/cli/node/files.py +14 -6
- vantage6/cli/node/list.py +18 -24
- vantage6/cli/node/new.py +21 -12
- vantage6/cli/node/remove.py +31 -22
- vantage6/cli/node/set_api_key.py +18 -12
- vantage6/cli/node/start.py +38 -12
- vantage6/cli/node/stop.py +32 -18
- vantage6/cli/node/version.py +23 -13
- vantage6/cli/rabbitmq/__init__.py +9 -9
- vantage6/cli/rabbitmq/definitions.py +24 -28
- vantage6/cli/rabbitmq/queue_manager.py +37 -40
- vantage6/cli/server/attach.py +16 -11
- vantage6/cli/server/common/__init__.py +37 -25
- vantage6/cli/server/files.py +1 -1
- vantage6/cli/server/import_.py +45 -37
- vantage6/cli/server/list.py +22 -23
- vantage6/cli/server/new.py +20 -14
- vantage6/cli/server/remove.py +5 -4
- vantage6/cli/server/shell.py +17 -6
- vantage6/cli/server/start.py +118 -174
- vantage6/cli/server/stop.py +31 -23
- vantage6/cli/server/version.py +16 -13
- vantage6/cli/test/common/diagnostic_runner.py +30 -34
- vantage6/cli/test/feature_tester.py +51 -25
- vantage6/cli/test/integration_test.py +69 -29
- vantage6/cli/utils.py +6 -5
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/METADATA +5 -3
- vantage6-4.3.0b3.dist-info/RECORD +68 -0
- vantage6/cli/context.py +0 -416
- vantage6-4.2.1.dist-info/RECORD +0 -58
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/WHEEL +0 -0
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/entry_points.txt +0 -0
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/top_level.txt +0 -0
tests_cli/test_example.py
CHANGED
tests_cli/test_node_cli.py
CHANGED
|
@@ -19,13 +19,10 @@ from vantage6.cli.node.stop import cli_node_stop
|
|
|
19
19
|
from vantage6.cli.node.attach import cli_node_attach
|
|
20
20
|
from vantage6.cli.node.create_private_key import cli_node_create_private_key
|
|
21
21
|
from vantage6.cli.node.clean import cli_node_clean
|
|
22
|
-
from vantage6.cli.node.common import
|
|
23
|
-
create_client_and_authenticate, print_log_worker
|
|
24
|
-
)
|
|
22
|
+
from vantage6.cli.node.common import create_client_and_authenticate, print_log_worker
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
class NodeCLITest(unittest.TestCase):
|
|
28
|
-
|
|
29
26
|
@classmethod
|
|
30
27
|
def setUpClass(cls):
|
|
31
28
|
logging.getLogger("docker.utils.config").setLevel(logging.WARNING)
|
|
@@ -34,7 +31,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
34
31
|
@patch("docker.DockerClient.ping")
|
|
35
32
|
def test_list_docker_not_running(self, docker_ping):
|
|
36
33
|
"""An error is printed when docker is not running"""
|
|
37
|
-
docker_ping.side_effect = Exception(
|
|
34
|
+
docker_ping.side_effect = Exception("Boom!")
|
|
38
35
|
|
|
39
36
|
runner = CliRunner()
|
|
40
37
|
result = runner.invoke(cli_node_list, [])
|
|
@@ -42,7 +39,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
42
39
|
# check exit code
|
|
43
40
|
self.assertEqual(result.exit_code, 1)
|
|
44
41
|
|
|
45
|
-
@patch("vantage6.cli.context.NodeContext.available_configurations")
|
|
42
|
+
@patch("vantage6.cli.context.node.NodeContext.available_configurations")
|
|
46
43
|
@patch("docker.DockerClient.ping")
|
|
47
44
|
@patch("docker.DockerClient.containers")
|
|
48
45
|
def test_list(self, containers, docker_ping, available_configurations):
|
|
@@ -82,7 +79,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
82
79
|
"-----------------------------------------------------\n"
|
|
83
80
|
"iknl Not running System \n"
|
|
84
81
|
"iknl Running User \n"
|
|
85
|
-
"-----------------------------------------------------\n"
|
|
82
|
+
"-----------------------------------------------------\n",
|
|
86
83
|
)
|
|
87
84
|
|
|
88
85
|
@patch("vantage6.cli.node.new.configuration_wizard")
|
|
@@ -95,9 +92,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
95
92
|
wizard.return_value = "/some/file/path"
|
|
96
93
|
|
|
97
94
|
runner = CliRunner()
|
|
98
|
-
result = runner.invoke(
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
result = runner.invoke(
|
|
96
|
+
cli_node_new_configuration,
|
|
97
|
+
[
|
|
98
|
+
"--name",
|
|
99
|
+
"some-name",
|
|
100
|
+
],
|
|
101
|
+
)
|
|
101
102
|
|
|
102
103
|
# check that info message is produced
|
|
103
104
|
self.assertEqual(result.output[:7], "[info ]")
|
|
@@ -110,13 +111,17 @@ class NodeCLITest(unittest.TestCase):
|
|
|
110
111
|
"""Whitespaces are replaced in the name."""
|
|
111
112
|
|
|
112
113
|
runner = CliRunner()
|
|
113
|
-
result = runner.invoke(
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
result = runner.invoke(
|
|
115
|
+
cli_node_new_configuration,
|
|
116
|
+
[
|
|
117
|
+
"--name",
|
|
118
|
+
"some name",
|
|
119
|
+
],
|
|
120
|
+
)
|
|
116
121
|
|
|
117
122
|
self.assertEqual(
|
|
118
123
|
result.output[:60],
|
|
119
|
-
"[info ] - Replaced spaces from configuration name: some-name"
|
|
124
|
+
"[info ] - Replaced spaces from configuration name: some-name",
|
|
120
125
|
)
|
|
121
126
|
|
|
122
127
|
@patch("vantage6.cli.node.new.NodeContext")
|
|
@@ -126,9 +131,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
126
131
|
context.config_exists.return_value = True
|
|
127
132
|
|
|
128
133
|
runner = CliRunner()
|
|
129
|
-
result = runner.invoke(
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
result = runner.invoke(
|
|
135
|
+
cli_node_new_configuration,
|
|
136
|
+
[
|
|
137
|
+
"--name",
|
|
138
|
+
"some-name",
|
|
139
|
+
],
|
|
140
|
+
)
|
|
132
141
|
|
|
133
142
|
# check that error is produced
|
|
134
143
|
self.assertEqual(result.output[:7], "[error]")
|
|
@@ -145,9 +154,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
145
154
|
permissions.return_value = False
|
|
146
155
|
|
|
147
156
|
runner = CliRunner()
|
|
148
|
-
result = runner.invoke(
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
result = runner.invoke(
|
|
158
|
+
cli_node_new_configuration,
|
|
159
|
+
[
|
|
160
|
+
"--name",
|
|
161
|
+
"some-name",
|
|
162
|
+
],
|
|
163
|
+
)
|
|
151
164
|
|
|
152
165
|
# check that error is produced
|
|
153
166
|
self.assertEqual(result.output[:7], "[error]")
|
|
@@ -163,12 +176,9 @@ class NodeCLITest(unittest.TestCase):
|
|
|
163
176
|
|
|
164
177
|
common_context.config_exists.return_value = True
|
|
165
178
|
context.return_value = MagicMock(
|
|
166
|
-
config_file="/file.yaml",
|
|
167
|
-
log_file="/log.log",
|
|
168
|
-
data_dir="/dir"
|
|
179
|
+
config_file="/file.yaml", log_file="/log.log", data_dir="/dir"
|
|
169
180
|
)
|
|
170
|
-
context.return_value.databases.items.return_value =
|
|
171
|
-
[["label", "/file.db"]]
|
|
181
|
+
context.return_value.databases.items.return_value = [["label", "/file.db"]]
|
|
172
182
|
select_config.return_value = "iknl"
|
|
173
183
|
|
|
174
184
|
runner = CliRunner()
|
|
@@ -187,7 +197,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
187
197
|
context.config_exists.return_value = False
|
|
188
198
|
|
|
189
199
|
runner = CliRunner()
|
|
190
|
-
result = runner.invoke(cli_node_files, [
|
|
200
|
+
result = runner.invoke(cli_node_files, ["--name", "non-existing"])
|
|
191
201
|
|
|
192
202
|
# Check that error is produced
|
|
193
203
|
self.assertEqual(result.output[:7], "[error]")
|
|
@@ -201,7 +211,6 @@ class NodeCLITest(unittest.TestCase):
|
|
|
201
211
|
@patch("docker.DockerClient.containers")
|
|
202
212
|
@patch("vantage6.cli.node.start.check_docker_running", return_value=True)
|
|
203
213
|
def test_start(self, check_docker, client, context, pull, volumes):
|
|
204
|
-
|
|
205
214
|
# client.containers = MagicMock(name="docker.DockerClient.containers")
|
|
206
215
|
client.list.return_value = []
|
|
207
216
|
volume = MagicMock()
|
|
@@ -213,39 +222,43 @@ class NodeCLITest(unittest.TestCase):
|
|
|
213
222
|
data_dir=Path("data"),
|
|
214
223
|
log_dir=Path("logs"),
|
|
215
224
|
config_dir=Path("configs"),
|
|
216
|
-
databases=[{
|
|
217
|
-
"label": "some_label",
|
|
218
|
-
"uri": "data.csv",
|
|
219
|
-
"type": "csv"
|
|
220
|
-
}]
|
|
225
|
+
databases=[{"label": "some_label", "uri": "data.csv", "type": "csv"}],
|
|
221
226
|
)
|
|
227
|
+
|
|
228
|
+
# cli_node_start() tests for truth value of a set-like object derived
|
|
229
|
+
# from ctx.config.get('node_extra_env', {}). Default MagicMock() will
|
|
230
|
+
# evaluate to True, empty dict to False. False signifies no overwritten
|
|
231
|
+
# env vars, hence no error.
|
|
232
|
+
def config_get_side_effect(key, default=None):
|
|
233
|
+
if key == "node_extra_env":
|
|
234
|
+
return {}
|
|
235
|
+
return MagicMock()
|
|
236
|
+
|
|
237
|
+
ctx.config.get.side_effect = config_get_side_effect
|
|
222
238
|
ctx.get_data_file.return_value = "data.csv"
|
|
223
|
-
ctx.name =
|
|
239
|
+
ctx.name = "some-name"
|
|
224
240
|
context.return_value = ctx
|
|
225
241
|
|
|
226
242
|
runner = CliRunner()
|
|
227
243
|
|
|
228
244
|
with runner.isolated_filesystem():
|
|
229
|
-
result = runner.invoke(cli_node_start, [
|
|
245
|
+
result = runner.invoke(cli_node_start, ["--name", "some-name"])
|
|
230
246
|
|
|
231
247
|
self.assertEqual(result.exit_code, 0)
|
|
232
248
|
|
|
233
249
|
@patch("docker.DockerClient.containers")
|
|
234
|
-
@patch("vantage6.cli.node.stop.check_docker_running",
|
|
235
|
-
return_value=True)
|
|
250
|
+
@patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
|
|
236
251
|
def test_stop(self, check_docker, containers):
|
|
237
|
-
|
|
238
252
|
container1 = MagicMock()
|
|
239
253
|
container1.name = f"{APPNAME}-iknl-user"
|
|
240
254
|
containers.list.return_value = [container1]
|
|
241
255
|
|
|
242
256
|
runner = CliRunner()
|
|
243
257
|
|
|
244
|
-
result = runner.invoke(cli_node_stop, [
|
|
258
|
+
result = runner.invoke(cli_node_stop, ["--name", "iknl"])
|
|
245
259
|
|
|
246
260
|
self.assertEqual(
|
|
247
|
-
result.output,
|
|
248
|
-
"[info ] - Stopped the vantage6-iknl-user Node.\n"
|
|
261
|
+
result.output, "[info ] - Stopped the vantage6-iknl-user Node.\n"
|
|
249
262
|
)
|
|
250
263
|
|
|
251
264
|
self.assertEqual(result.exit_code, 0)
|
|
@@ -264,13 +277,13 @@ class NodeCLITest(unittest.TestCase):
|
|
|
264
277
|
time_.sleep.side_effect = KeyboardInterrupt()
|
|
265
278
|
|
|
266
279
|
runner = CliRunner()
|
|
267
|
-
result = runner.invoke(cli_node_attach, [
|
|
280
|
+
result = runner.invoke(cli_node_attach, ["--name", "iknl"])
|
|
268
281
|
|
|
269
282
|
self.assertEqual(
|
|
270
283
|
result.output,
|
|
271
284
|
"[info ] - Closing log file. Keyboard Interrupt.\n"
|
|
272
285
|
"[info ] - Note that your node is still running! Shut it down "
|
|
273
|
-
"with 'v6 node stop'\n"
|
|
286
|
+
"with 'v6 node stop'\n",
|
|
274
287
|
)
|
|
275
288
|
self.assertEqual(result.exit_code, 0)
|
|
276
289
|
|
|
@@ -293,21 +306,17 @@ class NodeCLITest(unittest.TestCase):
|
|
|
293
306
|
# check exit code
|
|
294
307
|
self.assertEqual(result.exit_code, 0)
|
|
295
308
|
|
|
296
|
-
@patch(
|
|
297
|
-
"vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
309
|
+
@patch("vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
298
310
|
@patch("vantage6.cli.node.common.NodeContext")
|
|
299
311
|
@patch("vantage6.cli.node.create_private_key.NodeContext")
|
|
300
312
|
def test_create_private_key(self, context, common_context, client):
|
|
301
313
|
common_context.config_exists.return_value = True
|
|
302
314
|
context.return_value.type_data_folder.return_value = Path(".")
|
|
303
|
-
client.return_value = MagicMock(
|
|
304
|
-
whoami=MagicMock(organization_name="Test")
|
|
305
|
-
)
|
|
315
|
+
client.return_value = MagicMock(whoami=MagicMock(organization_name="Test"))
|
|
306
316
|
# client.whoami.organization_name = "Test"
|
|
307
317
|
runner = CliRunner()
|
|
308
318
|
|
|
309
|
-
result = runner.invoke(cli_node_create_private_key,
|
|
310
|
-
["--name", "application"])
|
|
319
|
+
result = runner.invoke(cli_node_create_private_key, ["--name", "application"])
|
|
311
320
|
|
|
312
321
|
self.assertEqual(result.exit_code, 0)
|
|
313
322
|
|
|
@@ -315,18 +324,16 @@ class NodeCLITest(unittest.TestCase):
|
|
|
315
324
|
os.remove("privkey_Test.pem")
|
|
316
325
|
|
|
317
326
|
@patch("vantage6.cli.node.create_private_key.RSACryptor")
|
|
318
|
-
@patch(
|
|
319
|
-
"vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
327
|
+
@patch("vantage6.cli.node.create_private_key.create_client_and_authenticate")
|
|
320
328
|
@patch("vantage6.cli.node.common.NodeContext")
|
|
321
329
|
@patch("vantage6.cli.node.create_private_key.NodeContext")
|
|
322
|
-
def test_create_private_key_overwite(
|
|
323
|
-
|
|
330
|
+
def test_create_private_key_overwite(
|
|
331
|
+
self, context, common_context, client, cryptor
|
|
332
|
+
):
|
|
324
333
|
common_context.config_exists.return_value = True
|
|
325
334
|
context.return_value.type_data_folder.return_value = Path(".")
|
|
326
|
-
client.return_value = MagicMock(
|
|
327
|
-
|
|
328
|
-
)
|
|
329
|
-
cryptor.create_public_key_bytes.return_value = b''
|
|
335
|
+
client.return_value = MagicMock(whoami=MagicMock(organization_name="Test"))
|
|
336
|
+
cryptor.create_public_key_bytes.return_value = b""
|
|
330
337
|
# client.whoami.organization_name = "Test"
|
|
331
338
|
|
|
332
339
|
runner = CliRunner()
|
|
@@ -336,13 +343,10 @@ class NodeCLITest(unittest.TestCase):
|
|
|
336
343
|
with open("privkey_iknl.pem", "w") as f:
|
|
337
344
|
f.write("does-not-matter")
|
|
338
345
|
|
|
339
|
-
result = runner.invoke(
|
|
340
|
-
|
|
341
|
-
"application",
|
|
342
|
-
|
|
343
|
-
"--organization-name",
|
|
344
|
-
"iknl"
|
|
345
|
-
])
|
|
346
|
+
result = runner.invoke(
|
|
347
|
+
cli_node_create_private_key,
|
|
348
|
+
["--name", "application", "--overwrite", "--organization-name", "iknl"],
|
|
349
|
+
)
|
|
346
350
|
self.assertEqual(result.exit_code, 0)
|
|
347
351
|
|
|
348
352
|
# do not overwrite
|
|
@@ -350,12 +354,10 @@ class NodeCLITest(unittest.TestCase):
|
|
|
350
354
|
with open("privkey_iknl.pem", "w") as f:
|
|
351
355
|
f.write("does-not-matter")
|
|
352
356
|
|
|
353
|
-
result = runner.invoke(
|
|
354
|
-
|
|
355
|
-
"application",
|
|
356
|
-
|
|
357
|
-
"iknl"
|
|
358
|
-
])
|
|
357
|
+
result = runner.invoke(
|
|
358
|
+
cli_node_create_private_key,
|
|
359
|
+
["--name", "application", "--organization-name", "iknl"],
|
|
360
|
+
)
|
|
359
361
|
|
|
360
362
|
# print(result.output)
|
|
361
363
|
|
|
@@ -366,8 +368,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
366
368
|
context.config_exists.return_value = False
|
|
367
369
|
|
|
368
370
|
runner = CliRunner()
|
|
369
|
-
result = runner.invoke(cli_node_create_private_key,
|
|
370
|
-
["--name", "application"])
|
|
371
|
+
result = runner.invoke(cli_node_create_private_key, ["--name", "application"])
|
|
371
372
|
|
|
372
373
|
self.assertEqual(result.exit_code, 1)
|
|
373
374
|
|
|
@@ -375,7 +376,6 @@ class NodeCLITest(unittest.TestCase):
|
|
|
375
376
|
@patch("docker.DockerClient.volumes")
|
|
376
377
|
@patch("vantage6.common.docker.addons.check_docker_running")
|
|
377
378
|
def test_clean_docker_error(self, check_docker, volumes, q):
|
|
378
|
-
|
|
379
379
|
volume1 = MagicMock()
|
|
380
380
|
volume1.name = "some-name-tmpvol"
|
|
381
381
|
volume1.remove.side_effect = APIError("Testing")
|
|
@@ -404,13 +404,8 @@ class NodeCLITest(unittest.TestCase):
|
|
|
404
404
|
@patch("vantage6.cli.node.common.UserClient")
|
|
405
405
|
@patch("vantage6.cli.node.common.q")
|
|
406
406
|
def test_client(self, q, client, error, debug, info):
|
|
407
|
-
|
|
408
407
|
ctx = MagicMock(
|
|
409
|
-
config={
|
|
410
|
-
"server_url": "localhost",
|
|
411
|
-
"port": 5000,
|
|
412
|
-
"api_path": ""
|
|
413
|
-
}
|
|
408
|
+
config={"server_url": "localhost", "port": 5000, "api_path": ""}
|
|
414
409
|
)
|
|
415
410
|
|
|
416
411
|
# should not trigger an exception
|
tests_cli/test_server_cli.py
CHANGED
|
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from click.testing import CliRunner
|
|
6
6
|
|
|
7
|
-
from vantage6.
|
|
7
|
+
from vantage6.common.globals import APPNAME, InstanceType
|
|
8
8
|
from vantage6.cli.server.start import cli_server_start
|
|
9
9
|
from vantage6.cli.server.list import cli_server_configuration_list
|
|
10
10
|
from vantage6.cli.server.files import cli_server_files
|
|
@@ -15,16 +15,23 @@ from vantage6.cli.server.attach import cli_server_attach
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class ServerCLITest(unittest.TestCase):
|
|
18
|
-
|
|
19
18
|
@patch("vantage6.cli.server.start.NetworkManager")
|
|
20
19
|
@patch("vantage6.cli.server.start.docker.types.Mount")
|
|
21
20
|
@patch("os.makedirs")
|
|
22
|
-
@patch("vantage6.cli.
|
|
21
|
+
@patch("vantage6.cli.common.start.pull_if_newer")
|
|
23
22
|
@patch("vantage6.cli.server.common.ServerContext")
|
|
24
23
|
@patch("vantage6.cli.server.start.docker.from_env")
|
|
25
|
-
@patch("vantage6.cli.
|
|
26
|
-
def test_start(
|
|
27
|
-
|
|
24
|
+
@patch("vantage6.cli.common.start.check_docker_running", return_value=True)
|
|
25
|
+
def test_start(
|
|
26
|
+
self,
|
|
27
|
+
docker_check,
|
|
28
|
+
containers,
|
|
29
|
+
context,
|
|
30
|
+
pull,
|
|
31
|
+
os_makedirs,
|
|
32
|
+
mount,
|
|
33
|
+
network_manager,
|
|
34
|
+
):
|
|
28
35
|
"""Start server without errors"""
|
|
29
36
|
container1 = MagicMock()
|
|
30
37
|
container1.containers.name = f"{APPNAME}-iknl-system"
|
|
@@ -34,15 +41,12 @@ class ServerCLITest(unittest.TestCase):
|
|
|
34
41
|
# mount.types.Mount.return_value = MagicMock()
|
|
35
42
|
|
|
36
43
|
ctx = MagicMock(
|
|
37
|
-
config={
|
|
38
|
-
'uri': 'sqlite:///file.db',
|
|
39
|
-
'port': 9999
|
|
40
|
-
},
|
|
44
|
+
config={"uri": "sqlite:///file.db", "port": 9999},
|
|
41
45
|
config_file="/config.yaml",
|
|
42
|
-
data_dir=Path(".")
|
|
46
|
+
data_dir=Path("."),
|
|
43
47
|
)
|
|
44
48
|
ctx.config_exists.return_value = True
|
|
45
|
-
ctx.name =
|
|
49
|
+
ctx.name = "not-running"
|
|
46
50
|
context.return_value = ctx
|
|
47
51
|
|
|
48
52
|
runner = CliRunner()
|
|
@@ -74,8 +78,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
74
78
|
"""Configuration files without errors."""
|
|
75
79
|
|
|
76
80
|
ctx = context.return_value = MagicMock(
|
|
77
|
-
log_file="/log_file.log",
|
|
78
|
-
config_file="/iknl.yaml"
|
|
81
|
+
log_file="/log_file.log", config_file="/iknl.yaml"
|
|
79
82
|
)
|
|
80
83
|
ctx.get_database_uri.return_value = "sqlite:///test.db"
|
|
81
84
|
|
|
@@ -88,24 +91,21 @@ class ServerCLITest(unittest.TestCase):
|
|
|
88
91
|
@patch("docker.DockerClient.containers")
|
|
89
92
|
@patch("vantage6.cli.server.import_.print_log_worker")
|
|
90
93
|
@patch("vantage6.cli.server.import_.click.Path")
|
|
91
|
-
@patch("vantage6.cli.server.import_.check_docker_running",
|
|
92
|
-
return_value=True)
|
|
94
|
+
@patch("vantage6.cli.server.import_.check_docker_running", return_value=True)
|
|
93
95
|
@patch("vantage6.cli.server.common.ServerContext")
|
|
94
96
|
def test_import(self, context, docker_check, click_path, log, containers):
|
|
95
97
|
"""Import entities without errors."""
|
|
96
98
|
click_path.return_value = MagicMock()
|
|
97
99
|
|
|
98
100
|
ctx = MagicMock()
|
|
99
|
-
ctx.name =
|
|
101
|
+
ctx.name = "some-name"
|
|
100
102
|
context.return_value = ctx
|
|
101
103
|
|
|
102
104
|
runner = CliRunner()
|
|
103
105
|
with runner.isolated_filesystem():
|
|
104
106
|
with open("some.yaml", "w") as fp:
|
|
105
107
|
fp.write("does-not-matter")
|
|
106
|
-
result = runner.invoke(cli_server_import, [
|
|
107
|
-
"--name", "iknl", "some.yaml"
|
|
108
|
-
])
|
|
108
|
+
result = runner.invoke(cli_server_import, ["--name", "iknl", "some.yaml"])
|
|
109
109
|
|
|
110
110
|
self.assertIsNone(result.exception)
|
|
111
111
|
self.assertEqual(result.exit_code, 0)
|
|
@@ -131,7 +131,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
131
131
|
"""Stop server without errors."""
|
|
132
132
|
|
|
133
133
|
container1 = MagicMock()
|
|
134
|
-
container1.name = f"{APPNAME}-iknl-system-
|
|
134
|
+
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
135
135
|
containers.containers.list.return_value = [container1]
|
|
136
136
|
|
|
137
137
|
runner = CliRunner()
|
|
@@ -145,7 +145,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
145
145
|
def test_attach(self, containers, sleep):
|
|
146
146
|
"""Attach log to the console without errors."""
|
|
147
147
|
container1 = MagicMock()
|
|
148
|
-
container1.name = f"{APPNAME}-iknl-system-
|
|
148
|
+
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
149
149
|
containers.list.return_value = [container1]
|
|
150
150
|
|
|
151
151
|
sleep.side_effect = KeyboardInterrupt("Boom!")
|
tests_cli/test_wizard.py
CHANGED
|
@@ -7,14 +7,14 @@ from vantage6.cli.configuration_wizard import (
|
|
|
7
7
|
node_configuration_questionaire,
|
|
8
8
|
server_configuration_questionaire,
|
|
9
9
|
configuration_wizard,
|
|
10
|
-
select_configuration_questionaire
|
|
10
|
+
select_configuration_questionaire,
|
|
11
11
|
)
|
|
12
|
+
from vantage6.common.globals import InstanceType
|
|
12
13
|
|
|
13
14
|
module_path = "vantage6.cli.configuration_wizard"
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class WizardTest(unittest.TestCase):
|
|
17
|
-
|
|
18
18
|
@staticmethod
|
|
19
19
|
def prompts(*args, **kwargs):
|
|
20
20
|
result = {}
|
|
@@ -39,30 +39,46 @@ class WizardTest(unittest.TestCase):
|
|
|
39
39
|
False, # don't enable two-factor authentication
|
|
40
40
|
True, # add VPN server
|
|
41
41
|
False, # don't abort if no server connection is made to pull
|
|
42
|
-
|
|
43
|
-
True # Enable encryption
|
|
42
|
+
# collaboration settings
|
|
43
|
+
True, # Enable encryption
|
|
44
44
|
]
|
|
45
45
|
dirs = MagicMock(data="/")
|
|
46
46
|
config = node_configuration_questionaire(dirs, "iknl")
|
|
47
47
|
|
|
48
|
-
keys = [
|
|
49
|
-
|
|
48
|
+
keys = [
|
|
49
|
+
"api_key",
|
|
50
|
+
"server_url",
|
|
51
|
+
"port",
|
|
52
|
+
"api_path",
|
|
53
|
+
"task_dir",
|
|
54
|
+
"databases",
|
|
55
|
+
"logging",
|
|
56
|
+
"encryption",
|
|
57
|
+
"vpn_subnet",
|
|
58
|
+
]
|
|
50
59
|
for key in keys:
|
|
51
60
|
self.assertIn(key, config)
|
|
52
61
|
|
|
53
62
|
def test_server_wizard(self):
|
|
54
|
-
|
|
55
63
|
with patch(f"{module_path}.q") as q:
|
|
56
64
|
q.prompt.side_effect = self.prompts
|
|
57
|
-
q.confirm.return_value.ask.side_effect = [
|
|
58
|
-
True, True, True, True, True
|
|
59
|
-
]
|
|
65
|
+
q.confirm.return_value.ask.side_effect = [True, True, True, True, True]
|
|
60
66
|
|
|
61
67
|
config = server_configuration_questionaire("vantage6")
|
|
62
68
|
|
|
63
|
-
keys = [
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
keys = [
|
|
70
|
+
"description",
|
|
71
|
+
"ip",
|
|
72
|
+
"port",
|
|
73
|
+
"api_path",
|
|
74
|
+
"uri",
|
|
75
|
+
"allow_drop_all",
|
|
76
|
+
"jwt_secret_key",
|
|
77
|
+
"logging",
|
|
78
|
+
"vpn_server",
|
|
79
|
+
"rabbitmq",
|
|
80
|
+
"two_factor_auth",
|
|
81
|
+
]
|
|
66
82
|
|
|
67
83
|
for key in keys:
|
|
68
84
|
self.assertIn(key, config)
|
|
@@ -71,31 +87,27 @@ class WizardTest(unittest.TestCase):
|
|
|
71
87
|
@patch(f"{module_path}.server_configuration_questionaire")
|
|
72
88
|
@patch(f"{module_path}.ServerConfigurationManager")
|
|
73
89
|
@patch(f"{module_path}.NodeConfigurationManager")
|
|
74
|
-
@patch(
|
|
75
|
-
def test_configuration_wizard_interface(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
file_ = configuration_wizard("node", "vtg6", False)
|
|
82
|
-
self.assertEqual(Path("/some/path/vtg6.yaml"), file_)
|
|
90
|
+
@patch("vantage6.cli.configuration_wizard.AppContext")
|
|
91
|
+
def test_configuration_wizard_interface(
|
|
92
|
+
self, context, node_m, server_m, server_q, node_q
|
|
93
|
+
):
|
|
94
|
+
context.instance_folders.return_value = {"config": "/some/path/"}
|
|
83
95
|
|
|
84
|
-
file_ = configuration_wizard(
|
|
96
|
+
file_ = configuration_wizard(InstanceType.NODE, "vtg6", False)
|
|
85
97
|
self.assertEqual(Path("/some/path/vtg6.yaml"), file_)
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def test_select_configuration(self, server_c, node_c):
|
|
99
|
+
file_ = configuration_wizard(InstanceType.SERVER, "vtg6", True)
|
|
100
|
+
self.assertEqual(Path("/some/path/vtg6.yaml"), file_)
|
|
90
101
|
|
|
102
|
+
@patch("vantage6.cli.configuration_wizard.AppContext.available_configurations")
|
|
103
|
+
def test_select_configuration(self, available_configurations):
|
|
91
104
|
config = MagicMock()
|
|
92
105
|
config.name = "vtg6"
|
|
93
106
|
|
|
94
|
-
|
|
95
|
-
node_c.available_configurations.return_value = [[config], []]
|
|
107
|
+
available_configurations.return_value = [[config], []]
|
|
96
108
|
|
|
97
109
|
with patch(f"{module_path}.q") as q:
|
|
98
110
|
q.select.return_value.ask.return_value = "vtg6"
|
|
99
|
-
name = select_configuration_questionaire(
|
|
111
|
+
name = select_configuration_questionaire(InstanceType.NODE, True)
|
|
100
112
|
|
|
101
113
|
self.assertEqual(name, "vtg6")
|
vantage6/cli/__build__
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3
|
vantage6/cli/_version.py
CHANGED
|
@@ -3,18 +3,21 @@ import json
|
|
|
3
3
|
|
|
4
4
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
5
5
|
|
|
6
|
-
with open(os.path.join(here,
|
|
6
|
+
with open(os.path.join(here, "__build__")) as fp:
|
|
7
7
|
__build__ = json.load(fp)
|
|
8
8
|
|
|
9
9
|
# Module version
|
|
10
|
-
version_info = (4,
|
|
10
|
+
version_info = (4, 3, 0, "beta", __build__, 0)
|
|
11
11
|
|
|
12
12
|
# Module version stage suffix map
|
|
13
|
-
_specifier_ = {
|
|
14
|
-
version = f
|
|
15
|
-
pre_release =
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}
|
|
14
|
+
version = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
|
|
15
|
+
pre_release = (
|
|
16
|
+
""
|
|
17
|
+
if version_info[3] == "final"
|
|
18
|
+
else _specifier_[version_info[3]] + str(version_info[4])
|
|
19
|
+
)
|
|
20
|
+
post_release = "" if not version_info[5] else f".post{version_info[5]}"
|
|
18
21
|
|
|
19
22
|
# Module version accessible using thomas.__version__
|
|
20
|
-
__version__ = f
|
|
23
|
+
__version__ = f"{version}{pre_release}{post_release}"
|
vantage6/cli/algorithm/create.py
CHANGED
|
@@ -10,13 +10,18 @@ from vantage6.cli.utils import info
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
13
|
-
@click.option(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
@click.option(
|
|
14
|
+
"-n", "--name", default=None, type=str, help="Name for your new algorithm"
|
|
15
|
+
)
|
|
16
|
+
@click.option(
|
|
17
|
+
"-d",
|
|
18
|
+
"--dir",
|
|
19
|
+
"directory",
|
|
20
|
+
default=None,
|
|
21
|
+
type=str,
|
|
22
|
+
help="Directory to put the algorithm into",
|
|
23
|
+
)
|
|
24
|
+
def cli_algorithm_create(name: str, directory: str) -> dict:
|
|
20
25
|
"""Creates a personalized template for a new algorithm
|
|
21
26
|
|
|
22
27
|
By answering a number of questions, a template will be created that will
|
|
@@ -34,14 +39,9 @@ def cli_algorithm_create(
|
|
|
34
39
|
if not directory:
|
|
35
40
|
default_dir = str(Path(os.getcwd()) / name)
|
|
36
41
|
directory = q.text(
|
|
37
|
-
"Directory to put the algorithm in:",
|
|
38
|
-
default=default_dir
|
|
42
|
+
"Directory to put the algorithm in:", default=default_dir
|
|
39
43
|
).ask()
|
|
40
44
|
|
|
41
|
-
run_copy(
|
|
42
|
-
ALGORITHM_TEMPLATE_REPO,
|
|
43
|
-
directory,
|
|
44
|
-
data={'algorithm_name': name}
|
|
45
|
-
)
|
|
45
|
+
run_copy(ALGORITHM_TEMPLATE_REPO, directory, data={"algorithm_name": name})
|
|
46
46
|
info("Template created!")
|
|
47
47
|
info(f"You can find your new algorithm in: {directory}")
|