diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 45cf6b69..b0592299 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -8,6 +8,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from project_config.settings import Epic +from release_plan.todo_table import EXEMPTIONS from failure import Failure from plan_store import jira_epic from plan_store.stores import Plan, Written @@ -278,7 +279,7 @@ class Filing(unittest.TestCase): def test_links_the_issue_as_blocked_by_each_blocker_once_filed(self): self.open = [issue("ABC-34"), issue("ABC-35")] self.assertEqual(self.add(FIELDS | {"Blocked by": "34, 35"}), Written(40)) - self.assertEqual([url for _, url, _ in self.calls][-3:], [ISSUES, LINKS, LINKS]) + self.assertEqual([(method, url) for method, url, _ in self.calls][-3:], [("POST", ISSUES), ("POST", LINKS), ("POST", LINKS)]) self.assertEqual(self.sent(LINKS), [{"type": {"name": "Blocks"}, "inwardIssue": {"key": f"ABC-{blocker}"}, "outwardIssue": {"key": "ABC-40"}} for blocker in (34, 35)]) def test_a_blocker_that_is_no_open_child_fails_before_anything_is_filed(self): @@ -293,6 +294,22 @@ class Filing(unittest.TestCase): self.assertIsInstance(self.add(FIELDS | change), Failure) self.assertEqual(self.calls, []) + def test_each_field_out_of_format_fails_saying_how(self): + cases = ( + ({"Tagline": "** **"}, "the item has no tagline"), + ({"L": "9"}, "item to file's L '9' is not a whole number from 1 to 4"), + ({"Exempt": "whim"}, f"the item's Exempt 'whim' is not empty or one of {', '.join(EXEMPTIONS[1:])}"), + ({"Blocked by": "ABC-34"}, "the item's Blocked by 'ABC-34' is not empty or IDs separated by \", \""), + ) + for change, reason in cases: + with self.subTest(change=change): + self.assertEqual(self.add(FIELDS | change), Failure(reason)) + self.assertEqual(self.add({name: value for name, value in FIELDS.items() if name != "Tagline"}), Failure("the item has no tagline")) + + def test_an_item_without_moves_files_with_none(self): + self.assertEqual(self.add({name: value for name, value in FIELDS.items() if name != "Moves"}), Written(40)) + self.assertEqual(self.sent(ISSUES)[0]["properties"][0]["value"]["Moves"], "") # type: ignore[index] + def test_a_field_the_plan_does_not_have_is_a_programming_error(self): with self.assertRaises(ValueError): self.add(FIELDS | {"Colour": "red"})