Answer stability round 1: 0 🔴, 1 🟡 (0 misread); check every field a read takes, ask for a parent by its key, and sort labels

This commit is contained in:
2026-11-18 10:46:07 +01:00
parent 080a6a8693
commit a29d2a2315
5 changed files with 103 additions and 66 deletions
+24 -18
View File
@@ -1,4 +1,4 @@
"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, builds an epic with no issues in new_store, and changes an issue as a person would in the tracker in assign and close."""
"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign and close change an issue as a person would in the tracker."""
import re
import typing
@@ -8,6 +8,7 @@ from failure import Failure
class EpicStoreContract:
assertEqual: typing.Callable[..., None]
assertIsInstance: typing.Callable[..., None]
subTest: typing.Callable[..., typing.ContextManager[None]]
def new_store(self) -> EpicStore:
@@ -36,47 +37,52 @@ class EpicStoreContract:
def test_reads_back_a_child_issue_it_filed(self) -> None:
store = self.new_store()
key = self.filed(store, store.epic, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("api", "security"))
self.assertEqual(self.issues(store), [EpicIssue(key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("api", "security"), None, "To Do", False, store.epic)])
key = self.filed(store, store.epic_key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("security", "api"))
self.assertEqual(self.issues(store), [EpicIssue(key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("api", "security"), None, "To Do", False, store.epic_key)])
def test_reads_back_a_sub_task_it_filed_after_its_parent(self) -> None:
store = self.new_store()
first = self.filed(store, store.epic, "Count the runs.")
second = self.filed(store, store.epic, "Ship the later thing.")
first = self.filed(store, store.epic_key, "Count the runs.")
second = self.filed(store, store.epic_key, "Ship the later thing.")
task = self.filed(store, first, "Count them in the api.", labels=("api",))
read = self.issues(store)
self.assertEqual([(issue.key, issue.parent) for issue in read], [(first, store.epic), (task, first), (second, store.epic)])
self.assertEqual([(issue.key, issue.parent) for issue in read], [(first, store.epic_key), (task, first), (second, store.epic_key)])
self.assertEqual((read[1].summary, read[1].labels, read[1].detail), ("Count them in the api.", ("api",), ""))
def test_files_each_issue_under_its_own_key_in_the_epics_project(self) -> None:
store = self.new_store()
child = self.filed(store, store.epic, "Count the runs.")
keys = [child, self.filed(store, store.epic, "Count the runs."), self.filed(store, child, "Count them in the api.")]
child = self.filed(store, store.epic_key, "Count the runs.")
keys = [child, self.filed(store, store.epic_key, "Count the runs."), self.filed(store, child, "Count them in the api.")]
self.assertEqual(len(set(keys)), 3)
project = store.epic.rpartition("-")[0]
project = store.epic_key.rpartition("-")[0]
self.assertEqual([re.fullmatch(f"{project}-[1-9][0-9]*", key) is not None for key in keys], [True] * 3)
def test_reads_the_assignee_and_a_done_status(self) -> None:
store = self.new_store()
first = self.filed(store, store.epic, "Count the runs.")
second = self.filed(store, store.epic, "Ship the later thing.")
first = self.filed(store, store.epic_key, "Count the runs.")
second = self.filed(store, store.epic_key, "Ship the later thing.")
self.assign(store, first, "Ada Lovelace")
self.close(store, second, "Done")
read = {issue.key: issue for issue in self.issues(store)}
self.assertEqual((read[first].assignee, read[first].status, read[first].done), ("Ada Lovelace", "To Do", False))
self.assertEqual((read[second].assignee, read[second].status, read[second].done), (None, "Done", True))
def test_refuses_to_file_under_an_issue_outside_the_epic_or_under_a_sub_task(self) -> None:
def test_refuses_to_file_under_a_sub_task(self) -> None:
store = self.new_store()
child = self.filed(store, store.epic, "Count the runs.")
child = self.filed(store, store.epic_key, "Count the runs.")
task = self.filed(store, child, "Count them in the api.")
for parent in (task, "ZZZ-1"):
with self.subTest(parent=parent):
self.assertEqual(store.file(parent, "Count more.", "", ()), Failure(f"{parent} is neither the epic {store.epic} nor one of its child issues, so nothing can be filed under it"))
self.assertEqual(store.file(task, "Count more.", "", ()), Failure(f"{task} is neither the epic {store.epic_key} nor one of its child issues, so nothing can be filed under it"))
self.assertEqual(len(self.issues(store)), 2)
def test_refuses_to_file_under_an_issue_outside_the_epic(self) -> None:
store = self.new_store()
for parent in ("ZZZ-1", "not a key"):
with self.subTest(parent=parent):
self.assertIsInstance(store.file(parent, "Count more.", "", ()), Failure)
self.assertEqual(self.issues(store), [])
def test_refuses_a_label_with_white_space_and_a_summary_of_two_lines(self) -> None:
store = self.new_store()
self.assertEqual(store.file(store.epic, "Count the runs.", "", ("two words",)), Failure("the label 'two words' is empty or holds white space"))
self.assertEqual(store.file(store.epic, "Count\nthe runs.", "", ()), Failure("the summary must be one line of text"))
self.assertEqual(store.file(store.epic_key, "Count the runs.", "", ("two words",)), Failure("the label 'two words' is empty or holds white space"))
self.assertEqual(store.file(store.epic_key, "Count\nthe runs.", "", ()), Failure("the summary must be one line of text"))
self.assertEqual(self.issues(store), [])