forked from google/kasane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cli.py
68 lines (50 loc) · 1.72 KB
/
test_cli.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# coding=utf-8
"""cli feature tests."""
from pytest_bdd import (parsers, scenario, given, when, then)
from kasane import cmd
@scenario('cli.feature', "Showing a simple Kasanefile")
def test_showing_a_simple_kasanefile():
pass
@scenario('cli.feature', "Showing a remote layer fails when the layer isn't vendored")
def test_fetiching_remote_layer_fails_when_not_vendored():
pass
@scenario('cli.feature', "Showing a remote layer works")
def test_showing_remote_layer_works():
pass
@scenario('layers.feature', "Combining two layers together")
def test_combining_two_layers_together():
pass
@scenario('layers.feature', "Using yamlenv loader substitutes ${ENV} with env values")
def test_yamlenv_loader():
pass
###
@given(parsers.parse("Kasanefile:\n{text}"))
def kasanefile(tmpdir, text):
tmpdir.join('Kasanefile').write(text)
return {'output': None}
###
@when(parsers.parse("a layer named '{name}' contains:\n{text}"))
def named_layer(tmpdir, name, text):
tmpdir.join(name).write(text)
@when(parsers.parse("user runs kasane {action}"))
def run_kasane_action(kasanefile, cli_runner, tmpdir, action):
try:
old_dir = tmpdir.chdir()
# TODO(farcaller): fix the highlight breakage
if action == 'show':
args = ['-r']
else:
args = []
kasanefile['output'] = cli_runner.invoke(cmd.cli, [action, *args])
except:
raise
finally:
old_dir.chdir()
###
@then(parsers.parse("kasane outputs:\n{text}"))
def kasane_outputs(kasanefile, text):
assert kasanefile['output'].output == text + '\n'
@then(parsers.parse("kasane fails with a message '{message}'"))
def kasane_fails_with_message(kasanefile, message):
assert kasanefile['output'].exit_code == 1
assert kasanefile['output'].output == message + '\n'