forked from feathr-ai/feathr
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_cli.py
More file actions
38 lines (28 loc) · 1.19 KB
/
test_cli.py
File metadata and controls
38 lines (28 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from feathrcli.cli import init
from click.testing import CliRunner
import os
import glob
def test_workspace_creation():
"""
Test CLI init() is working properly.
"""
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(init, [])
assert result.exit_code == 0
assert os.path.isdir("./feathr_user_workspace")
total_yaml_files = glob.glob('./feathr_user_workspace/*.yaml', recursive=True)
# we should have exact 1 yaml file
assert len(total_yaml_files) == 1
# result = runner.invoke(init, [])
test_folder_name = 'test_folder'
result = runner.invoke(init, ['--name', test_folder_name])
assert result.exit_code == 0
total_yaml_files = glob.glob(os.path.join(test_folder_name, '*.yaml'), recursive=True)
# we should have exact 1 yaml file
assert len(total_yaml_files) == 1
result = runner.invoke(init, ["--name", test_folder_name])
assert result.exit_code == 2
# use output for test for now
expected_out = f'Feathr workspace ({test_folder_name}) already exist. Please use a new folder name.\n'
assert expected_out in result.output