codeplain 0.3.13.dev49__py3-none-any.whl → 0.3.14.dev50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- change_detection.py +65 -94
- cli_output/dry_run.py +7 -3
- {codeplain-0.3.13.dev49.dist-info → codeplain-0.3.14.dev50.dist-info}/METADATA +1 -1
- {codeplain-0.3.13.dev49.dist-info → codeplain-0.3.14.dev50.dist-info}/RECORD +49 -43
- codeplain_REST_api.py +9 -14
- docs/generate_cli.py +3 -2
- partial_rendering.py +32 -2
- plain2code.py +42 -14
- plain2code_arguments.py +69 -12
- plain2code_telemetry.py +2 -1
- plain2code_utils.py +14 -0
- plain_modules.py +73 -14
- render_machine/actions/analyze_specification_ambiguity.py +5 -3
- render_machine/actions/distill_conformance_test_memory.py +3 -1
- render_machine/actions/fix_conformance_test.py +4 -4
- render_machine/actions/fix_unit_tests.py +3 -1
- render_machine/actions/refactor_code.py +6 -1
- render_machine/actions/render_conformance_tests.py +52 -20
- render_machine/actions/render_functional_requirement.py +5 -2
- render_machine/actions/run_conformance_tests.py +3 -2
- render_machine/actions/summarize_conformance_tests.py +3 -1
- render_machine/render_context.py +59 -20
- render_machine/render_types.py +6 -15
- standard_template_library/typescript-react-app-boilerplate.plain +2 -1
- tests/test_acceptance_scenario_rendered_once.py +169 -0
- tests/test_acceptance_scenarios_after_a_code_fix.py +110 -0
- tests/test_change_detection.py +138 -127
- tests/test_conformance_fix_journal.py +46 -46
- tests/test_dry_run_link_validation.py +2 -1
- tests/test_fix_unit_tests_action.py +1 -1
- tests/test_frid_arguments.py +40 -0
- tests/test_functionality_without_scenarios.py +88 -0
- tests/test_git_utils.py +13 -13
- tests/test_partial_rendering.py +82 -47
- tests/test_plain2code.py +39 -41
- tests/test_plain2code_utils.py +12 -1
- tests/test_plain_modules.py +50 -44
- tests/test_render_finished_report.py +2 -0
- tests/test_render_range.py +18 -9
- tests/test_render_stop_reason.py +5 -5
- tests/test_telemetry.py +2 -2
- tests/test_terminal_attachment.py +2 -1
- tests/test_tests_folders.py +91 -0
- tests/test_traceability_warnings.py +69 -0
- tui/plain_module_render_choice_tui.py +4 -6
- tui/state_handlers.py +19 -28
- {codeplain-0.3.13.dev49.dist-info → codeplain-0.3.14.dev50.dist-info}/WHEEL +0 -0
- {codeplain-0.3.13.dev49.dist-info → codeplain-0.3.14.dev50.dist-info}/entry_points.txt +0 -0
- {codeplain-0.3.13.dev49.dist-info → codeplain-0.3.14.dev50.dist-info}/licenses/LICENSE +0 -0
|
@@ -23,7 +23,7 @@ def journal(memory_folder):
|
|
|
23
23
|
def record_full_attempt(
|
|
24
24
|
journal,
|
|
25
25
|
module="mod",
|
|
26
|
-
frid="
|
|
26
|
+
frid="add-task",
|
|
27
27
|
attempt=1,
|
|
28
28
|
diff=None,
|
|
29
29
|
summary=None,
|
|
@@ -63,19 +63,19 @@ class TestNormalizedDiffHash:
|
|
|
63
63
|
|
|
64
64
|
class TestJournalEntries:
|
|
65
65
|
def test_attempt_lifecycle_is_recorded(self, journal):
|
|
66
|
-
journal.open_attempt("mod", "
|
|
66
|
+
journal.open_attempt("mod", "add-task", 1, "raw failure output")
|
|
67
67
|
journal.record_fix(
|
|
68
68
|
"mod",
|
|
69
|
-
"
|
|
69
|
+
"add-task",
|
|
70
70
|
{"hypothesis": "the root cause", "approach": "the fix"},
|
|
71
71
|
["src/app.py"],
|
|
72
72
|
"IMPLEMENTATION_CODE",
|
|
73
73
|
{"src/app.py": "diff"},
|
|
74
74
|
"the issue as the fixer saw it",
|
|
75
75
|
)
|
|
76
|
-
journal.record_result("mod", "
|
|
76
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
77
77
|
|
|
78
|
-
[entry] = journal._read_entries("mod", "
|
|
78
|
+
[entry] = journal._read_entries("mod", "add-task")
|
|
79
79
|
assert entry["attempt"] == 1
|
|
80
80
|
assert entry["issue_before_raw"] == "raw failure output"
|
|
81
81
|
assert entry["issue_before"] == "the issue as the fixer saw it"
|
|
@@ -87,36 +87,36 @@ class TestJournalEntries:
|
|
|
87
87
|
|
|
88
88
|
def test_raw_issue_is_stored_untruncated(self, journal):
|
|
89
89
|
long_issue = "x" * (MAX_ISSUE_EXCERPT_CHARS * 3) + "THE END"
|
|
90
|
-
journal.open_attempt("mod", "
|
|
90
|
+
journal.open_attempt("mod", "add-task", 1, long_issue)
|
|
91
91
|
|
|
92
|
-
[entry] = journal._read_entries("mod", "
|
|
92
|
+
[entry] = journal._read_entries("mod", "add-task")
|
|
93
93
|
assert entry["issue_before_raw"] == long_issue
|
|
94
94
|
|
|
95
95
|
def test_a_passing_result_is_recorded(self, journal):
|
|
96
96
|
record_full_attempt(journal)
|
|
97
|
-
journal.record_result("mod", "
|
|
97
|
+
journal.record_result("mod", "add-task", passed=True)
|
|
98
98
|
|
|
99
|
-
[entry] = journal._read_entries("mod", "
|
|
99
|
+
[entry] = journal._read_entries("mod", "add-task")
|
|
100
100
|
assert entry["result"] == "conformance tests passed"
|
|
101
101
|
|
|
102
102
|
def test_record_result_without_a_pending_attempt_does_nothing(self, journal):
|
|
103
|
-
journal.record_result("mod", "
|
|
103
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
104
104
|
|
|
105
|
-
assert journal._read_entries("mod", "
|
|
105
|
+
assert journal._read_entries("mod", "add-task") == []
|
|
106
106
|
|
|
107
107
|
def test_record_result_does_not_overwrite_a_completed_attempt(self, journal):
|
|
108
108
|
record_full_attempt(journal)
|
|
109
|
-
journal.record_result("mod", "
|
|
110
|
-
journal.record_result("mod", "
|
|
109
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
110
|
+
journal.record_result("mod", "add-task", passed=True)
|
|
111
111
|
|
|
112
|
-
[entry] = journal._read_entries("mod", "
|
|
112
|
+
[entry] = journal._read_entries("mod", "add-task")
|
|
113
113
|
assert entry["result"] == "conformance tests still failed"
|
|
114
114
|
|
|
115
115
|
def test_missing_summary_and_prepared_issue_leave_the_entry_without_them(self, journal):
|
|
116
|
-
journal.open_attempt("mod", "
|
|
117
|
-
journal.record_fix("mod", "
|
|
116
|
+
journal.open_attempt("mod", "add-task", 1, "failure")
|
|
117
|
+
journal.record_fix("mod", "add-task", None, ["src/app.py"], "IMPLEMENTATION_CODE", {"src/app.py": "diff"}, None)
|
|
118
118
|
|
|
119
|
-
[entry] = journal._read_entries("mod", "
|
|
119
|
+
[entry] = journal._read_entries("mod", "add-task")
|
|
120
120
|
assert "hypothesis" not in entry
|
|
121
121
|
assert "approach" not in entry
|
|
122
122
|
assert "issue_before" not in entry
|
|
@@ -126,37 +126,37 @@ class TestDuplicateDetection:
|
|
|
126
126
|
def test_a_repeated_diff_is_marked_as_a_duplicate(self, journal):
|
|
127
127
|
diff = {"src/app.py": "+ same change"}
|
|
128
128
|
record_full_attempt(journal, attempt=1, diff=diff)
|
|
129
|
-
journal.record_result("mod", "
|
|
129
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
130
130
|
record_full_attempt(journal, attempt=2, diff={"src/app.py": "+ same change "})
|
|
131
131
|
|
|
132
|
-
entries = journal._read_entries("mod", "
|
|
132
|
+
entries = journal._read_entries("mod", "add-task")
|
|
133
133
|
assert "duplicate_of" not in entries[0]
|
|
134
134
|
assert entries[1]["duplicate_of"] == 1
|
|
135
135
|
|
|
136
136
|
def test_a_different_diff_is_not_marked(self, journal):
|
|
137
137
|
record_full_attempt(journal, attempt=1, diff={"src/app.py": "+ change one"})
|
|
138
|
-
journal.record_result("mod", "
|
|
138
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
139
139
|
record_full_attempt(journal, attempt=2, diff={"src/app.py": "+ change two"})
|
|
140
140
|
|
|
141
|
-
entries = journal._read_entries("mod", "
|
|
141
|
+
entries = journal._read_entries("mod", "add-task")
|
|
142
142
|
assert "duplicate_of" not in entries[1]
|
|
143
143
|
|
|
144
144
|
def test_attempts_without_a_diff_are_never_duplicates(self, journal):
|
|
145
145
|
record_full_attempt(journal, attempt=1, diff={}, files=[])
|
|
146
|
-
journal.record_result("mod", "
|
|
146
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
147
147
|
record_full_attempt(journal, attempt=2, diff={}, files=[])
|
|
148
148
|
|
|
149
|
-
entries = journal._read_entries("mod", "
|
|
149
|
+
entries = journal._read_entries("mod", "add-task")
|
|
150
150
|
assert "duplicate_of" not in entries[1]
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
class TestDigest:
|
|
154
154
|
def test_digest_carries_the_compact_history_with_prepared_issues(self, journal):
|
|
155
155
|
record_full_attempt(journal, attempt=1, prepared_issue="issue as fixer saw it 1")
|
|
156
|
-
journal.record_result("mod", "
|
|
156
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
157
157
|
record_full_attempt(journal, attempt=2, prepared_issue="issue as fixer saw it 2")
|
|
158
158
|
|
|
159
|
-
digest = journal.build_digest("mod", "
|
|
159
|
+
digest = journal.build_digest("mod", "add-task")
|
|
160
160
|
|
|
161
161
|
assert [entry["attempt"] for entry in digest] == [1, 2]
|
|
162
162
|
assert digest[0]["result"] == "conformance tests still failed"
|
|
@@ -173,76 +173,76 @@ class TestDigest:
|
|
|
173
173
|
long_prepared = "x" * (MAX_ISSUE_EXCERPT_CHARS + 100) + "THE END"
|
|
174
174
|
record_full_attempt(journal, prepared_issue=long_prepared)
|
|
175
175
|
|
|
176
|
-
[entry] = journal.build_digest("mod", "
|
|
176
|
+
[entry] = journal.build_digest("mod", "add-task")
|
|
177
177
|
assert entry["issue"].endswith("THE END")
|
|
178
178
|
assert len(entry["issue"]) < len(long_prepared)
|
|
179
179
|
|
|
180
180
|
def test_digest_of_an_attempt_without_a_prepared_issue_has_no_issue(self, journal):
|
|
181
181
|
record_full_attempt(journal, prepared_issue=None)
|
|
182
182
|
|
|
183
|
-
[entry] = journal.build_digest("mod", "
|
|
183
|
+
[entry] = journal.build_digest("mod", "add-task")
|
|
184
184
|
assert "issue" not in entry
|
|
185
185
|
|
|
186
186
|
def test_the_open_attempt_is_excluded_from_the_digest(self, journal):
|
|
187
187
|
"""The entry opened for the attempt about to be made carries nothing yet - the fixer must
|
|
188
188
|
not see an empty attempt in its history."""
|
|
189
189
|
record_full_attempt(journal, attempt=1)
|
|
190
|
-
journal.record_result("mod", "
|
|
191
|
-
journal.open_attempt("mod", "
|
|
190
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
191
|
+
journal.open_attempt("mod", "add-task", 2, "current failure output")
|
|
192
192
|
|
|
193
|
-
digest = journal.build_digest("mod", "
|
|
193
|
+
digest = journal.build_digest("mod", "add-task")
|
|
194
194
|
|
|
195
195
|
assert [entry["attempt"] for entry in digest] == [1]
|
|
196
196
|
|
|
197
197
|
def test_a_dangling_attempt_without_a_fix_is_excluded_from_the_digest(self, journal):
|
|
198
198
|
"""An interrupted render can leave an opened entry that later gets a result but never a fix."""
|
|
199
|
-
journal.open_attempt("mod", "
|
|
200
|
-
journal.record_result("mod", "
|
|
199
|
+
journal.open_attempt("mod", "add-task", 1, "failure output")
|
|
200
|
+
journal.record_result("mod", "add-task", passed=False)
|
|
201
201
|
|
|
202
|
-
assert journal.build_digest("mod", "
|
|
202
|
+
assert journal.build_digest("mod", "add-task") == []
|
|
203
203
|
|
|
204
204
|
def test_digest_of_an_unknown_frid_is_empty(self, journal):
|
|
205
|
-
assert journal.build_digest("mod", "
|
|
205
|
+
assert journal.build_digest("mod", "no-such-task") == []
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
class TestCollectAndClear:
|
|
209
209
|
def test_collect_all_groups_by_module_and_frid(self, journal):
|
|
210
|
-
record_full_attempt(journal, module="mod", frid="
|
|
211
|
-
record_full_attempt(journal, module="other_module", frid="
|
|
210
|
+
record_full_attempt(journal, module="mod", frid="add-task")
|
|
211
|
+
record_full_attempt(journal, module="other_module", frid="list-tasks")
|
|
212
212
|
|
|
213
213
|
journals = journal.collect_all()
|
|
214
214
|
|
|
215
|
-
assert [(j["module"], j["frid"]) for j in journals] == [("mod", "
|
|
215
|
+
assert [(j["module"], j["frid"]) for j in journals] == [("mod", "add-task"), ("other_module", "list-tasks")]
|
|
216
216
|
assert journals[0]["initial_issue"] == "prepared issue"
|
|
217
217
|
assert journals[0]["attempts"][0]["hypothesis"] == "hypothesis 1"
|
|
218
218
|
|
|
219
219
|
def test_initial_issue_falls_back_to_the_trimmed_raw_output(self, journal):
|
|
220
220
|
long_raw = "x" * (MAX_ISSUE_EXCERPT_CHARS + 100) + "THE END"
|
|
221
|
-
journal.open_attempt("mod", "
|
|
222
|
-
journal.record_fix("mod", "
|
|
221
|
+
journal.open_attempt("mod", "add-task", 1, long_raw)
|
|
222
|
+
journal.record_fix("mod", "add-task", None, [], "IMPLEMENTATION_CODE", None, None)
|
|
223
223
|
|
|
224
224
|
[collected] = journal.collect_all()
|
|
225
225
|
assert collected["initial_issue"].endswith("THE END")
|
|
226
226
|
assert len(collected["initial_issue"]) < len(long_raw)
|
|
227
227
|
|
|
228
228
|
def test_module_names_containing_double_underscores_are_parsed(self, journal):
|
|
229
|
-
record_full_attempt(journal, module="my__module", frid="
|
|
229
|
+
record_full_attempt(journal, module="my__module", frid="rename-task")
|
|
230
230
|
|
|
231
231
|
[collected] = journal.collect_all()
|
|
232
232
|
assert collected["module"] == "my__module"
|
|
233
|
-
assert collected["frid"] == "
|
|
233
|
+
assert collected["frid"] == "rename-task"
|
|
234
234
|
|
|
235
235
|
def test_collect_all_without_journals_is_empty(self, journal):
|
|
236
236
|
assert journal.collect_all() == []
|
|
237
237
|
|
|
238
238
|
def test_collect_all_skips_a_journal_holding_only_an_open_attempt(self, journal):
|
|
239
|
-
journal.open_attempt("mod", "
|
|
239
|
+
journal.open_attempt("mod", "add-task", 1, "failure output")
|
|
240
240
|
|
|
241
241
|
assert journal.collect_all() == []
|
|
242
242
|
|
|
243
243
|
def test_clear_all_removes_every_journal(self, journal):
|
|
244
|
-
record_full_attempt(journal, module="mod", frid="
|
|
245
|
-
record_full_attempt(journal, module="mod", frid="
|
|
244
|
+
record_full_attempt(journal, module="mod", frid="add-task")
|
|
245
|
+
record_full_attempt(journal, module="mod", frid="list-tasks")
|
|
246
246
|
|
|
247
247
|
journal.clear_all()
|
|
248
248
|
|
|
@@ -251,9 +251,9 @@ class TestCollectAndClear:
|
|
|
251
251
|
|
|
252
252
|
def test_malformed_lines_are_skipped(self, journal, memory_folder):
|
|
253
253
|
record_full_attempt(journal)
|
|
254
|
-
with open(journal._journal_path("mod", "
|
|
254
|
+
with open(journal._journal_path("mod", "add-task"), "a") as journal_file:
|
|
255
255
|
journal_file.write("not json\n")
|
|
256
256
|
journal_file.write(json.dumps({"attempt": 2, "issue_before_raw": "x"}) + "\n")
|
|
257
257
|
|
|
258
|
-
entries = journal._read_entries("mod", "
|
|
258
|
+
entries = journal._read_entries("mod", "add-task")
|
|
259
259
|
assert [entry["attempt"] for entry in entries] == [1, 2]
|
|
@@ -65,7 +65,7 @@ def render_context(tmp_path, monkeypatch):
|
|
|
65
65
|
unit_tests_running_context=UnitTestsRunningContext(fix_attempts=1),
|
|
66
66
|
conformance_tests_running_context=None,
|
|
67
67
|
script_execution_history=ScriptExecutionHistory(),
|
|
68
|
-
get_required_modules_functionalities=lambda: {"base": ["- Base feature."]},
|
|
68
|
+
get_required_modules_functionalities=lambda: {"base": [{"id": "base-feature", "markdown": "- Base feature."}]},
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""--render-range and --render-from take func-ids."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from plain2code_arguments import parse_arguments
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _parse(tmp_path, *extra_args):
|
|
9
|
+
plain_file = tmp_path / "project.plain"
|
|
10
|
+
plain_file.write_text("***functional specs***\n\n# add-task\nA :User: can add a :Task:.\n")
|
|
11
|
+
return parse_arguments([str(plain_file), *extra_args])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_render_from_takes_a_func_id(tmp_path):
|
|
15
|
+
args = _parse(tmp_path, "--render-from", "add-task")
|
|
16
|
+
|
|
17
|
+
assert args.render_from == "add-task"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_render_range_takes_two_func_ids(tmp_path):
|
|
21
|
+
args = _parse(tmp_path, "--render-range", "add-task,list-tasks")
|
|
22
|
+
|
|
23
|
+
assert args.render_range == "add-task,list-tasks"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_render_range_takes_one_func_id(tmp_path):
|
|
27
|
+
args = _parse(tmp_path, "--render-range", "add-task")
|
|
28
|
+
|
|
29
|
+
assert args.render_range == "add-task"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.parametrize("value", ["Add-Task", "add task", "add_task", "add.task", ""])
|
|
33
|
+
def test_a_value_that_is_not_a_func_id_is_rejected(tmp_path, value):
|
|
34
|
+
with pytest.raises(SystemExit):
|
|
35
|
+
_parse(tmp_path, "--render-from", value)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_a_range_of_more_than_two_func_ids_is_rejected(tmp_path):
|
|
39
|
+
with pytest.raises(SystemExit):
|
|
40
|
+
_parse(tmp_path, "--render-range", "add-task,list-tasks,rename-task")
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""A functionality whose test plain file holds no scenario: it is rendered, without conformance tests.
|
|
2
|
+
|
|
3
|
+
A functionality with no test plain file at all is a different case and stops the run.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
import file_utils # noqa: F401 # imported before plain_modules, which it imports back from
|
|
11
|
+
import plain2code
|
|
12
|
+
from plain_modules import PlainModule
|
|
13
|
+
|
|
14
|
+
MODULE = "required_with_acceptance_tests.plain"
|
|
15
|
+
EMPTY_TEST_PLAIN_FILE = """---
|
|
16
|
+
module: required_with_acceptance_tests
|
|
17
|
+
func_id: entry-point
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
***conformance tests***
|
|
21
|
+
|
|
22
|
+
***acceptance tests***
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.fixture
|
|
27
|
+
def project(tmp_path, get_test_data_path):
|
|
28
|
+
"""A copy of the fixture project, so a test can edit its test plain files."""
|
|
29
|
+
import shutil
|
|
30
|
+
|
|
31
|
+
source = get_test_data_path("data/acceptance_tests_warning")
|
|
32
|
+
specs = tmp_path / "specs"
|
|
33
|
+
shutil.copytree(source, specs)
|
|
34
|
+
return specs
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _build(project, tmp_path, module=MODULE):
|
|
38
|
+
return PlainModule(
|
|
39
|
+
module,
|
|
40
|
+
str(tmp_path / "build"),
|
|
41
|
+
[str(project)],
|
|
42
|
+
[str(project / "tests")],
|
|
43
|
+
conformance_tests_enabled=True,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_a_test_plain_file_with_a_scenario_is_not_reported(project, tmp_path):
|
|
48
|
+
module = _build(project, tmp_path)
|
|
49
|
+
|
|
50
|
+
assert module.functionalities_without_scenarios == []
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_a_test_plain_file_without_scenarios_is_reported(project, tmp_path):
|
|
54
|
+
(project / "tests" / "required_with_acceptance_tests" / "entry-point.plain").write_text(EMPTY_TEST_PLAIN_FILE)
|
|
55
|
+
|
|
56
|
+
module = _build(project, tmp_path)
|
|
57
|
+
|
|
58
|
+
assert module.functionalities_without_scenarios == [("required_with_acceptance_tests", "entry-point")]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_a_missing_test_plain_file_stops_the_run(project, tmp_path):
|
|
62
|
+
os.remove(project / "tests" / "required_with_acceptance_tests" / "entry-point.plain")
|
|
63
|
+
|
|
64
|
+
with pytest.raises(Exception, match="has no test plain file"):
|
|
65
|
+
_build(project, tmp_path)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_the_warning_names_every_functionality_without_scenarios(project, tmp_path, monkeypatch):
|
|
69
|
+
(project / "tests" / "required_with_acceptance_tests" / "entry-point.plain").write_text(EMPTY_TEST_PLAIN_FILE)
|
|
70
|
+
module = _build(project, tmp_path)
|
|
71
|
+
|
|
72
|
+
warnings = []
|
|
73
|
+
monkeypatch.setattr(plain2code.console, "warning", lambda message: warnings.append(message))
|
|
74
|
+
plain2code.warn_about_functionalities_without_scenarios(module)
|
|
75
|
+
|
|
76
|
+
assert len(warnings) == 1
|
|
77
|
+
assert "required_with_acceptance_tests:entry-point" in warnings[0]
|
|
78
|
+
assert "without conformance tests" in warnings[0]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_nothing_is_warned_when_every_functionality_has_a_scenario(project, tmp_path, monkeypatch):
|
|
82
|
+
module = _build(project, tmp_path)
|
|
83
|
+
|
|
84
|
+
warnings = []
|
|
85
|
+
monkeypatch.setattr(plain2code.console, "warning", lambda message: warnings.append(message))
|
|
86
|
+
plain2code.warn_about_functionalities_without_scenarios(module)
|
|
87
|
+
|
|
88
|
+
assert warnings == []
|
tests/test_git_utils.py
CHANGED
|
@@ -455,20 +455,20 @@ def test_get_last_finished_frid_returns_latest(empty_repo):
|
|
|
455
455
|
file_path.write_text("v1")
|
|
456
456
|
add_all_files_and_commit(
|
|
457
457
|
empty_repo,
|
|
458
|
-
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("
|
|
458
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("add-task"),
|
|
459
459
|
module_name="module_a",
|
|
460
|
-
frid="
|
|
460
|
+
frid="add-task",
|
|
461
461
|
)
|
|
462
462
|
|
|
463
463
|
file_path.write_text("v2")
|
|
464
464
|
add_all_files_and_commit(
|
|
465
465
|
empty_repo,
|
|
466
|
-
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("
|
|
466
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("list-tasks"),
|
|
467
467
|
module_name="module_a",
|
|
468
|
-
frid="
|
|
468
|
+
frid="list-tasks",
|
|
469
469
|
)
|
|
470
470
|
|
|
471
|
-
assert get_last_rendered_functionality(empty_repo) == ("module_a", "
|
|
471
|
+
assert get_last_rendered_functionality(empty_repo) == ("module_a", "list-tasks")
|
|
472
472
|
|
|
473
473
|
|
|
474
474
|
def test_get_last_finished_frid_ignores_non_finished_commits(empty_repo):
|
|
@@ -477,22 +477,22 @@ def test_get_last_finished_frid_ignores_non_finished_commits(empty_repo):
|
|
|
477
477
|
file_path.write_text("v1")
|
|
478
478
|
add_all_files_and_commit(
|
|
479
479
|
empty_repo,
|
|
480
|
-
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("
|
|
480
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("add-task"),
|
|
481
481
|
module_name="module_a",
|
|
482
|
-
frid="
|
|
482
|
+
frid="add-task",
|
|
483
483
|
)
|
|
484
484
|
|
|
485
485
|
# A refactor commit (not a finished-frid checkpoint) comes after.
|
|
486
486
|
file_path.write_text("v2")
|
|
487
487
|
add_all_files_and_commit(
|
|
488
488
|
empty_repo,
|
|
489
|
-
REFACTORED_CODE_COMMIT_MESSAGE.format("
|
|
489
|
+
REFACTORED_CODE_COMMIT_MESSAGE.format("list-tasks"),
|
|
490
490
|
module_name="module_a",
|
|
491
|
-
frid="
|
|
491
|
+
frid="list-tasks",
|
|
492
492
|
)
|
|
493
493
|
|
|
494
|
-
# The last *finished* FRID is still
|
|
495
|
-
assert get_last_rendered_functionality(empty_repo) == ("module_a", "
|
|
494
|
+
# The last *finished* FRID is still add-task
|
|
495
|
+
assert get_last_rendered_functionality(empty_repo) == ("module_a", "add-task")
|
|
496
496
|
|
|
497
497
|
|
|
498
498
|
def test_get_last_finished_frid_without_module_name(empty_repo):
|
|
@@ -501,9 +501,9 @@ def test_get_last_finished_frid_without_module_name(empty_repo):
|
|
|
501
501
|
file_path.write_text("v1")
|
|
502
502
|
add_all_files_and_commit(
|
|
503
503
|
empty_repo,
|
|
504
|
-
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("
|
|
504
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("rename-task"),
|
|
505
505
|
module_name=None,
|
|
506
|
-
frid="
|
|
506
|
+
frid="rename-task",
|
|
507
507
|
)
|
|
508
508
|
|
|
509
509
|
with pytest.raises(InvalidGitRepositoryError, match="Could not find module name in finished commit"):
|