casebench
test cases straight onto the board.
git clone https://owenrusk.dev/casebench.git
commit 6d91ae011f7271c920f7cf632d70f2dc3fe0972e parent 867ea6227889a5eb4d6fd5f714462a1ea0d89119 author Owen Rusk <owen@papermothgames.com> date 2026-03-17 14:22:49 -0500
casefile: svg images tess draws the simple ones as svg. the umbrella has a picture now.
| casebench/casefile.py | +1 | -0 |
| examples/lost-umbrella/case.yaml | +1 | -0 |
| examples/lost-umbrella/items/umbrella.svg | +8 | -0 |
| tests/test_casefile.py | +10 | -0 |
| tests/test_commands.py | +1 | -0 |
diff --git a/casebench/casefile.py b/casebench/casefile.py index 243b26f..def4767 100644 --- a/casebench/casefile.py +++ b/casebench/casefile.py @@ -10,6 +10,7 @@ MEDIA = { ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", + ".svg": "image/svg+xml", } diff --git a/examples/lost-umbrella/case.yaml b/examples/lost-umbrella/case.yaml index da8ba93..f3d1ef5 100644 --- a/examples/lost-umbrella/case.yaml +++ b/examples/lost-umbrella/case.yaml @@ -11,3 +11,4 @@ items: - id: umbrella title: The umbrella text: items/umbrella.md + images: [items/umbrella.svg] diff --git a/examples/lost-umbrella/items/umbrella.svg b/examples/lost-umbrella/items/umbrella.svg new file mode 100644 index 0000000..332483e --- /dev/null +++ b/examples/lost-umbrella/items/umbrella.svg @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="240" height="240"> + <rect width="120" height="120" fill="#f4f1ea"/> + <path d="M15 58 Q60 8 105 58 Q93 50 82 58 Q71 50 60 58 Q49 50 38 58 Q27 50 15 58 Z" fill="#2f4f8f"/> + <path d="M60 58 V98 Q60 108 51 108 Q44 108 44 100" fill="none" stroke="#7a5230" stroke-width="5" stroke-linecap="round"/> + <path d="M82 58 L90 49" stroke="#1d3463" stroke-width="2"/> + <rect x="55" y="74" width="10" height="7" fill="#fff" stroke="#999" stroke-width="0.5"/> + <text x="60" y="79.5" font-family="monospace" font-size="4.5" text-anchor="middle">114</text> +</svg> diff --git a/tests/test_casefile.py b/tests/test_casefile.py index dedb0d9..0a193e6 100644 --- a/tests/test_casefile.py +++ b/tests/test_casefile.py @@ -22,6 +22,16 @@ class CaseFileTest(unittest.TestCase): self.assertEqual(case.id, "test-lost-umbrella") self.assertEqual([item.id for item in case.items], ["ticket", "log", "umbrella"]) self.assertIn("No. 114", case.items[0].text) + (image,) = case.items[2].images + self.assertEqual((image.name, image.mime), ("umbrella.svg", "image/svg+xml")) + + def test_image_it_cant_serve(self): + root = self.folder( + "id: x\ntitle: X\nitems:\n - id: a\n title: A\n text: a.md\n images: [a.tiff]\n", + {"a.md": "a", "a.tiff": "not really"}, + ) + with self.assertRaisesRegex(CaseError, "can't serve a.tiff"): + load(root) def test_no_case_yaml(self): tmp = tempfile.TemporaryDirectory() diff --git a/tests/test_commands.py b/tests/test_commands.py index bfcd71f..92ed6d7 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -16,6 +16,7 @@ class PutTest(unittest.TestCase): self.assertEqual(out, "owen: put test-lost-umbrella\n") self.assertEqual(self.store.items(self.owen, "test-lost-umbrella"), ["ticket", "log", "umbrella"]) self.assertIsNone(self.store.placed(self.store.player("tess"), "test-lost-umbrella")) + self.assertEqual([image.mime for image in self.store.media.values()], ["image/svg+xml"]) def test_putting_again_keeps_notes_and_lock(self): run(self.store, "put", str(UMBRELLA), "--player", "owen")