Answer stability round 1: 1 🔴, 4 🟡 (0 misread); run the stranded held_at test, and test a blocked row, an edit without a detail and an ID that prefixes another
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import dataclasses
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -71,6 +72,17 @@ class FilePlan(FilePlanContract):
|
||||
self.assertEqual([note.split(": ")[0] for note in written.notes], [str(self.folder / "todo.md")])
|
||||
self.assertIn("item 1 ", written.notes[0])
|
||||
|
||||
def test_only_the_item_written_refuses_the_write(self):
|
||||
store = self.new_store()
|
||||
first = self.filed(store, FIRST)
|
||||
todo = self.folder / "todo.md"
|
||||
todo.write_text(todo.read_text().replace("`Next ID = 2`", "`Next ID = 10`"))
|
||||
self.assertEqual(self.filed(store, FIRST), 10)
|
||||
todo.write_text("".join(line.replace("| 4 | 1 | 1 by 9 |", "| 4 | 10 | 1 by 9 |") if line.startswith("| 10 ") else line for line in todo.read_text().splitlines(keepends=True)))
|
||||
written = store.edit(first, {"E": "2"}, None)
|
||||
assert isinstance(written, stores.Written), written
|
||||
self.assertIn("item 10 ", written.notes[0])
|
||||
|
||||
def test_a_missing_file_fails_naming_it(self):
|
||||
store = self.new_store()
|
||||
(self.folder / "todo.md").unlink()
|
||||
@@ -104,6 +116,7 @@ class FilePlan(FilePlanContract):
|
||||
self.assertEqual(store.edit(id_, {}, "### Why\n"), Failure(split))
|
||||
self.assertEqual((self.folder / "todo.md").read_text(), before)
|
||||
|
||||
@unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory")
|
||||
def test_a_file_it_cannot_write_fails_naming_it(self):
|
||||
store = self.new_store()
|
||||
self.folder.chmod(0o555)
|
||||
@@ -140,9 +153,12 @@ class HeldAt(unittest.TestCase):
|
||||
|
||||
self.assertEqual(stores.held_at("origin/main", held, "/checkout", run), held.read())
|
||||
|
||||
def test_fails_where_the_revision_cannot_be_read(self):
|
||||
def run(*args, cwd):
|
||||
return Failure("no git") if args[0] == "ls-tree" else "a commit\n"
|
||||
|
||||
self.assertEqual(stores.held_at("origin/main", MemoryPlan(tracked="todo.md"), "/checkout", run), Failure("no git"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
def test_fails_where_the_revision_cannot_be_read(self):
|
||||
self.assertEqual(stores.held_at("origin/main", MemoryPlan(tracked="todo.md"), "/checkout", lambda *args, cwd: Failure("no git")), Failure("no git"))
|
||||
|
||||
Reference in New Issue
Block a user