Test a drop title read through a template and two more branch faults

This commit is contained in:
2026-11-14 01:21:53 +01:00
parent 3aa53d8ae6
commit 1692679985
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -255,10 +255,10 @@ class BranchChunks(unittest.TestCase):
self.env.pop(name)
return self.git("rev-parse", "--short", "HEAD").strip()
def read(self, run=None):
def read(self, run=None, **template):
"""branch_chunks over main, run by git_repo's git, or else by run."""
with unittest.mock.patch.dict(os.environ, self.env, clear=True):
return branch_chunks("main", functools.partial(run or git, cwd=str(self.checkout)))
return branch_chunks("main", functools.partial(run or git, cwd=str(self.checkout)), **template)
def fixing_history(self):
"""Merges seven chunks onto main, then checks out a branch off it. Returns each of main's chunks by label, with the chunks that fixed it.
@@ -316,6 +316,13 @@ class BranchChunks(unittest.TestCase):
self.assertNotIsInstance(found, Failure)
self.assertEqual([([item.id for item in found.shipped], found.fixed_by) for found in found[:2]], [([], ()), ([4], ())])
def test_reads_a_drop_title_through_the_projects_commit_title(self):
self.merge("four", "Do four", {"b.py": "x\ny\n", "todo.md": todo(SECOND, FIX)}, "2026-10-13T10:00:00Z")
self.merge("six", "PAY-6 Drop item 6: item 4 fixed it", {"b.py": "x\nY\n", "todo.md": todo(SECOND)}, "2026-10-14T10:00:00Z")
found = self.read(template="PAY-{id} {summary}")
self.assertNotIsInstance(found, Failure)
self.assertEqual([[item.id for item in found.shipped] for found in found[:2]], [[], [4]])
def test_fails_where_git_cannot_read_the_branch(self):
self.assertEqual(branch_chunks("main", lambda *args: Failure("no log")), Failure("no log"))
+1 -1
View File
@@ -19,7 +19,7 @@ class TitleTest(unittest.TestCase):
for template in ("item-{id}", "feature/PAY-{id}", "{id}"):
with self.subTest(template):
self.assertIsNone(branch_fault(template))
for template in ("feature", "{id}-{summary}", "{id}/{id}", "feature/ PAY-{id}", "-{id}", "a..b{id}", "{id}.lock", "/{id}", "{id}/", "a~{id}", 3):
for template in ("feature", "{id}-{summary}", "{id}/{id}", "feature/ PAY-{id}", "-{id}", "a..b{id}", "{id}.lock", "/{id}", "{id}/", "a~{id}", ".hidden/{id}", "{id}.", 3):
with self.subTest(template):
self.assertIsNotNone(branch_fault(template))