Test plan_reasons in process with the plan and the decisions outside the checkout
This commit is contained in:
@@ -8,6 +8,7 @@ import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
@@ -576,6 +577,19 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertEqual(due.returncode, 0, due.stderr)
|
||||
self.assertTrue(due.stdout.startswith("Scoring run due:"), due.stdout)
|
||||
self.assertIn("floor", due.stdout)
|
||||
# In this process too, where the mutation tests see it.
|
||||
self.addCleanup(os.chdir, os.getcwd())
|
||||
os.chdir(self.checkout)
|
||||
with unittest.mock.patch.dict(os.environ, {"HOME": str(self.config.parents[2])}):
|
||||
self.assertEqual(plan_reasons("origin/main", [2]), ["ships item 2, a floor item", "leaves release 0.2.0 with no plan item"])
|
||||
(self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n")
|
||||
self.assertEqual(plan_reasons("origin/main", [2]), [])
|
||||
(self.config.parent / "decisions.md").unlink()
|
||||
(self.config.parent / "todo.md").write_bytes(b"\xff")
|
||||
unreadable = plan_reasons("origin/main", [2])
|
||||
assert isinstance(unreadable, Failure), unreadable
|
||||
self.assertTrue(unreadable.reason.startswith(f"cannot read {self.config.parent}/todo.md: "), unreadable.reason)
|
||||
(self.config.parent / "todo.md").write_text(todo(row, "| 2 | 0.2.0 | | **Reach the comprehension floor: do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |"))
|
||||
(self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n")
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user