Bnot : split large copies into pieces.
This commit is contained in:
1 parent
834ffe32f2
commit
1959c5d3bb
10 files changed
+333
-52
No files matched your search
+22
-6
@@ -2338,12 +2338,28 @@ class StandardCliTests(unittest.TestCase):
|
||||
("01", "Ex 2", image, 0, []),
|
||||
("02", "Ex 1", image, 0, []),
|
||||
]
|
||||
with patch.object(module, "MAX_HEIGHT_PX", 100), self.assertRaises(
|
||||
CliError
|
||||
) as raised:
|
||||
module.split_batches(rendered)
|
||||
self.assertIn("Copie01", str(raised.exception))
|
||||
self.assertIn("cannot be split", str(raised.exception))
|
||||
with patch.object(module, "MAX_HEIGHT_PX", 100):
|
||||
batches = module.split_batches(rendered)
|
||||
self.assertEqual(batches, [rendered[:2], rendered[2:]])
|
||||
|
||||
def test_grouped_oversized_answer_is_saved_as_its_own_group(self) -> None:
|
||||
module = self.modules["annotating_by_label"]
|
||||
rendered = [
|
||||
("01", "Ex 1", Image.new("RGB", (10, 40)), 0, []),
|
||||
("02", "Ex 1", Image.new("RGB", (10, 120)), 0, []),
|
||||
("03", "Ex 1", Image.new("RGB", (10, 50)), 0, []),
|
||||
]
|
||||
with tempfile.TemporaryDirectory() as directory, patch.object(module, "MAX_HEIGHT_PX", 100):
|
||||
batches = module.split_batches(rendered)
|
||||
self.assertEqual(batches, [[rendered[0], rendered[2]], [rendered[1]]])
|
||||
for index, batch in enumerate(batches, start=1):
|
||||
module.save_batch(batch, "Ex 1", index, Path(directory))
|
||||
metadata = read_json(Path(directory) / "Ex 1 G2/bnote.json")
|
||||
self.assertEqual(metadata["height"], 120)
|
||||
self.assertEqual([item["id"] for item in metadata["images"]], ["02"])
|
||||
self.assertTrue((Path(directory) / "Ex 1 G2/Concat.pdf").is_file())
|
||||
with self.assertRaises(CliError):
|
||||
module.save_batch(rendered[:2], "Ex 1", 3, Path(directory))
|
||||
|
||||
def test_grouped_batching_reuses_space_in_earlier_groups(self) -> None:
|
||||
module = self.modules["annotating_by_label"]
|
||||
|
||||
Reference in new issue
Block a user