You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// spec:4.3.6:The after stage MUST run after flag resolution occurs. It accepts a hook context (required), flag evaluation details (required) and hook hints (optional). It has no return value.:end
7
7
"""
8
-
cfg= {
8
+
cfg: Config= {
9
+
'file_extension': 'rust',
9
10
'multiline_regex': r'spec:(.*):end',
10
11
'number_subregex': r'(?P<number>[\d.]+):',
11
12
'text_subregex': r'[\d.]+:(.*)',
@@ -14,7 +15,7 @@ def test_simple_singleline():
14
15
output=find_covered_specs(cfg, text)
15
16
assert'4.3.6'inoutput
16
17
assert (
17
-
output['4.3.6']['text']
18
+
output['4.3.6']
18
19
=='The after stage MUST run after flag resolution occurs. It accepts a hook context (required), flag evaluation details (required) and hook hints (optional). It has no return value.'
19
20
)
20
21
@@ -26,7 +27,8 @@ def test_multiline_comment():
26
27
// context (required), exception representing what went wrong (required), and
27
28
// hook hints (optional). It has no return value.:end
28
29
"""
29
-
cfg= {
30
+
cfg: Config= {
31
+
'file_extension': 'rust',
30
32
'multiline_regex': r'spec:(.*):end',
31
33
'number_subregex': r'(?P<number>[\d.]+):',
32
34
'text_subregex': r'[\d.]+:(.*)',
@@ -35,7 +37,7 @@ def test_multiline_comment():
35
37
output=find_covered_specs(cfg, text)
36
38
assert'4.3.7'inoutput
37
39
assert (
38
-
output['4.3.7']['text']
40
+
output['4.3.7']
39
41
=="""The error hook MUST run when errors are encountered in the before stage, the after stage or during flag resolution. It accepts hook context (required), exception representing what went wrong (required), and hook hints (optional). It has no return value."""
40
42
)
41
43
@@ -59,7 +61,68 @@ def test_report():
59
61
assertlen(report['missing']) ==1
60
62
assertlen(report['extra']) ==1
61
63
62
-
assertreport['good'] ==set(['1.2.3'])
63
-
assertreport['different-text'] ==set(['2.3.4'])
64
-
assertreport['missing'] ==set(['3.4.5'])
65
-
assertreport['extra'] ==set(['4.5.6'])
64
+
assertreport['good'] == ['1.2.3']
65
+
assertreport['different-text'] == ['2.3.4']
66
+
assertreport['missing'] == ['3.4.5']
67
+
assertreport['extra'] == ['4.5.6']
68
+
69
+
70
+
deftest_report_with_found_spec():
71
+
spec= {
72
+
'4.3.6': 'good text',
73
+
}
74
+
text="""
75
+
// spec:4.3.6:good text:end
76
+
"""
77
+
cfg: Config= {
78
+
'file_extension': 'rust',
79
+
'multiline_regex': r'spec:(.*):end',
80
+
'number_subregex': r'(?P<number>[\d.]+):',
81
+
'text_subregex': r'[\d.]+:(.*)',
82
+
'inline_comment_prefix': '//',
83
+
}
84
+
output=find_covered_specs(cfg, text)
85
+
report=gen_report(spec, output)
86
+
87
+
assertreport['good'] == ['4.3.6']
88
+
89
+
90
+
deftest_specmap_from_file():
91
+
actual_spec= {
92
+
'rules': [
93
+
{
94
+
'id': 'Requirement 1.1.1',
95
+
'machine_id': 'requirement_1_1_1',
96
+
'content': 'The `API`, and any state it maintains SHOULD exist as a global singleton, even in cases wherein multiple versions of the `API` are present at runtime.',
97
+
'RFC 2119 keyword': 'SHOULD',
98
+
'children': [],
99
+
},
100
+
{
101
+
'id': 'Condition 2.2.2',
102
+
'machine_id': 'condition_2_2_2',
103
+
'content': 'The implementing language type system differentiates between strings, numbers, booleans and structures.',
104
+
'RFC 2119 keyword': None,
105
+
'children': [
106
+
{
107
+
'id': 'Conditional Requirement 2.2.2.1',
108
+
'machine_id': 'conditional_requirement_2_2_2_1',
109
+
'content': 'The `feature provider` interface MUST define methods for typed flag resolution, including boolean, numeric, string, and structure.',
110
+
'RFC 2119 keyword': 'MUST',
111
+
'children': [],
112
+
}
113
+
],
114
+
},
115
+
]
116
+
}
117
+
118
+
spec_map=specmap_from_file(actual_spec)
119
+
120
+
assertlen(spec_map) ==2
121
+
assert (
122
+
spec_map['1.1.1']
123
+
=='The API, and any state it maintains SHOULD exist as a global singleton, even in cases wherein multiple versions of the API are present at runtime.'
124
+
)
125
+
assert (
126
+
spec_map['2.2.2.1']
127
+
=='The feature provider interface MUST define methods for typed flag resolution, including boolean, numeric, string, and structure.'
0 commit comments