-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_validation.py
109 lines (84 loc) · 2.56 KB
/
test_validation.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pytest
from common import *
def test_no_rif_file_version():
"""RIF files must specify a version"""
output, return_code = run_rif(
[make_test_file_path('no-version.rif')],
)
expected_output = """
Invalid .rif file:
- rif_version is required
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_version_too_high():
"""The RIF file version must not be higher than the current major"""
output, return_code = run_rif(
[make_test_file_path('bad-version.rif')],
)
expected_output = """
Invalid .rif file:
- rif_version must not be greater than the maximum supported version (0)
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_url_missing():
"""RIF files must specify a URL"""
output, return_code = run_rif(
[make_test_file_path('missing-url.rif')],
)
expected_output = """
Invalid .rif file:
- Field "url" is required
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_method_missing():
"""RIF files must specify a method"""
output, return_code = run_rif(
[make_test_file_path('missing-method.rif')],
)
expected_output = """
Invalid .rif file:
- Field "method" is required
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_invalid_method():
"""RIF files must contain a valid HTTP method"""
output, return_code = run_rif(
[make_test_file_path('bad-method.rif')],
)
expected_output = """
Invalid .rif file:
- Method "NOTAVALIDMETHOD" is invalid
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_invalid_variable_type():
"""RIF files must contain valid variable types"""
output, return_code = run_rif(
[make_test_file_path('bad-variable-type.rif')],
)
expected_output = """
Invalid .rif file:
- Variable "foo" is invalid: variable has invalid type "notavalidtype" (valid types are boolean, number and string)
"""[1:-1]
assert return_code == 1
assert expected_output in output
def test_missing_required_variables():
"""RIF files must provide values for all required variables"""
output, return_code = run_rif(
[make_test_file_path('required-variables.rif')],
)
expected_output = """
Invalid parameters:
Missing required variable(s): VAR_A
The variables for this RIF file are as follows:
Required:
- VAR_A ( number )
Optional:
- VAR_B ( string, default=value )
"""[1:-1]
assert return_code == 1
assert expected_output in output