ocrd_utils.make_file_id: add test for multiple numbers in ID
@@ -293,6 +293,16 @@ class TestUtils(TestCase):
f = mets.add_file('2:!GRP', ID='FOO_0002', pageId='phys0002')
self.assertEqual(make_file_id(f, '2:!GRP'), 'id_2_GRP_0002')
+ def test_make_file_id_744(self):
+ """
+ https://github.com/OCR-D/core/pull/744
+ > Often file IDs have two numbers, one of which will clash. In that case only the numerical fallback works.
+ """
+ mets = OcrdMets.empty_mets()
+ f = mets.add_file('2:!GRP', ID='img1796-97_00000024_img', pageId='phys0024')
+ f = mets.add_file('2:!GRP', ID='img1796-97_00000025_img', pageId='phys0025')
+ self.assertEqual(make_file_id(f, '2:!GRP'), 'id_2_GRP_0025')
+
def test_generate_range(self):
assert generate_range('PHYS_0001', 'PHYS_0005') == ['PHYS_0001', 'PHYS_0002', 'PHYS_0003', 'PHYS_0004', 'PHYS_0005']
with self.assertRaisesRegex(ValueError, 'Unable to generate range'):
