This repository has been archived by the owner on Jun 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_stack_yaml.py
73 lines (52 loc) · 2.88 KB
/
test_stack_yaml.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
69
70
71
72
73
import os
def test_stack_functions(stack_data):
errMsg = 'Error: \'stack.yml\' file does not contain any functions.'
assert 'functions' in stack_data, errMsg
def test_git_ignore(stack_dir):
path = os.path.join(stack_dir, '.gitignore')
errMsg = f'Error: No \'.gitignore\' file found in {stack_dir}.'
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_handlers(stack_function, stack_dir):
path = os.path.join(stack_dir, stack_function['handler'])
errMsg = f'Error: No directory for {stack_function["handler"]}.'
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_handlers_file(stack_function, stack_dir):
path = os.path.join(stack_dir, stack_function['handler'], 'handler.py')
errMsg = (f'Error: \'{stack_function["handler"]}\' does not contain '
'\'handler.py\' file.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_handlers_requires(stack_function, stack_dir):
path = os.path.join(stack_dir, stack_function['handler'],
'requirements.txt')
errMsg = (f'Error: \'{stack_function["handler"]}\' does not contain '
'\'requirements.txt\' file.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_handlers_init(stack_function, stack_dir):
path = os.path.join(stack_dir, stack_function['handler'],
'__init__.py')
errMsg = (f'Error: \'{stack_function["handler"]}\' does not contain '
'\'__init__.py\' file.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_langs(stack_function, stack_dir):
path = os.path.join(stack_dir, 'template', stack_function['lang'])
errMsg = (f'Error: No directory for {stack_function["lang"]} is present in '
'\'template\' directory.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_langs_dockerfile(stack_function, stack_dir):
path = os.path.join(stack_dir, 'template', stack_function['lang'],
'Dockerfile')
errMsg = (f'Error: \'template/{stack_function["lang"]}/\' does not contain '
'\'Dockerfile\'.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_stack_langs_requires(stack_function, stack_dir):
path = os.path.join(stack_dir, 'template', stack_function['lang'],
'requirements.txt')
errMsg = (f'Error: \'template/{stack_function["lang"]}/\' does not contain '
'\'requirements.txt\' file.')
assert os.path.exists(os.path.realpath(path)), errMsg
def test_only_langs(stack_data, stack_dir):
lang_set = {v['lang'] for k, v in stack_data['functions'].items()}
dir_set = set(os.listdir(os.path.join(stack_dir, 'template')))
warnMsg = ('Warning: Unused language templates are present in \'template\' '
'directory.')
assert len(dir_set - lang_set) == 0, warnMsg