38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import unittest
|
|
|
|
from tests.fakes import FakeGitea, FakeModel, gitea_file
|
|
from tests.test_flow import run
|
|
from werkrevisor.rules import DIFF_MARKER_NOTE
|
|
|
|
PLAN = "doc/werkregie.werkbaum"
|
|
|
|
|
|
def plan_diff(context):
|
|
lines = [f"diff --git a/{PLAN} b/{PLAN}", f"--- a/{PLAN}", f"+++ b/{PLAN}", "@@ -1,2 +1,3 @@",
|
|
" " + context, "+ - [ ] #dash.taiga: Taiga", " #dash.taiga"]
|
|
return "\n".join(lines) + "\n"
|
|
|
|
|
|
def instructions(context):
|
|
model = FakeModel(prompt_files=[PLAN])
|
|
run(FakeGitea(files=[gitea_file(PLAN)], diff=plan_diff(context)), model)
|
|
return model.calls[0]
|
|
|
|
|
|
class DiffMarkerNoteTest(unittest.TestCase):
|
|
def test_an_unchanged_line_with_a_plus_gets_the_note(self):
|
|
"""Scenario#80.01"""
|
|
self.assertIn(DIFF_MARKER_NOTE, instructions(" + [?] #dash.notify: Matrix as a notification channel"))
|
|
|
|
def test_a_plain_diff_gets_no_note(self):
|
|
"""Scenario#80.02"""
|
|
self.assertNotIn(DIFF_MARKER_NOTE, instructions("[~] #werkregie: Werkregie"))
|
|
|
|
def test_an_unchanged_markdown_item_gets_the_note(self):
|
|
"""Scenario#80.01"""
|
|
self.assertIn(DIFF_MARKER_NOTE, instructions("- an item of a list"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|