Skip to content

Commit

Permalink
Testcase for #52: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hnesk committed Feb 21, 2023
1 parent c5b5fef commit 94a5bb5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/model/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def test_get_image_paths_only_returns_matching_groups(self):
self.assertEqual('OCR-D-IMG-BIN_0001.IMG-BIN.png', image_paths['PHYS_0017'].name)
self.assertEqual('OCR-D-IMG-BIN_0002.IMG-BIN.png', image_paths['PHYS_0020'].name)

def test_get_image_path_with_remote_image(self):
path = TEST_BASE_PATH / 'example/workspaces/remote/mets.xml'
for file_group_dir in path.parent.glob('OCR-D-*'):
shutil.rmtree(file_group_dir)
doc = Document.load(path.as_uri())
paths = doc.get_image_paths(FileGroupHandle('OCR-D-IMG-BIN', 'image/tiff'))
self.assertGreater(len(paths), 0)
self.assertIsInstance(list(paths.values())[0], Path)


def test_get_default_image_group(self):
doc = Document.load(ASSETS_PATH / 'kant_aufklaerung_1784-complex/data/mets.xml')
file_group = doc.get_default_image_group(['OCR-D-IMG-BIN', 'OCR-D-IMG.*'])
Expand Down Expand Up @@ -189,12 +199,3 @@ def test_missing_image(self):
image, info, exif = page.get_image(feature_selector='', feature_filter='binarized')
# Assert no exceptions happened and no image returned
self.assertIsNone(image)

def test_remote_image(self):
path = TEST_BASE_PATH / 'example/workspaces/remote/mets.xml'
for file_group_dir in path.parent.glob('OCR-D-*'):
shutil.rmtree(file_group_dir)
doc = Document.load(path.as_uri())
paths = doc.get_image_paths(FileGroupHandle('OCR-D-IMG-BIN', 'image/tiff'))
self.assertGreater(len(paths), 0)
self.assertIsInstance(list(paths.values())[0], Path)

0 comments on commit 94a5bb5

Please sign in to comment.