Skip to content

Commit

Permalink
[app][fix] typerror for mets contans fgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
M3ssman committed Apr 16, 2024
1 parent ecc5430 commit c791023
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "digiflow"
version = "3.9.1"
version = "3.9.2"
description = "Father's Little Digitization Workflow Helper"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
3 changes: 2 additions & 1 deletion src/digiflow/digiflow_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def contains_group(self, group: 'str|List[str]') -> bool:
if isinstance(group, list):
return any(self.tree.findall(PATTERN_FILEGROUP_USE.format(g), XMLNS)
for g in group)
return self.tree.findall(PATTERN_FILEGROUP_USE.format(group), XMLNS) > 0
_fgroups = self.tree.findall(PATTERN_FILEGROUP_USE.format(group), XMLNS)
return len(_fgroups) > 0

def clear_filegroups(self, black_list=None):
"""Clear file Groups by blacklist"""
Expand Down
17 changes: 17 additions & 0 deletions tests/test_digiflow_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,20 @@ def test_metsreader_kitodo2_mena_periodical_volume_dmd_id():

# assert
assert mets_reader.dmd_id == 'DMDLOG_0001'


def test_metadata_processor_contains_single_fgroup():
"""Ensure behavior for passing single str arg
Bugfix:
TypeError: '>' not supported between instances of 'list' and 'int'
"""

_proc = MetsProcessor(TEST_RES / 'k2_mets_morbio_1748529021.xml')
assert _proc.contains_group('MAX')


def test_metadata_processor_contains_multiple_fgroup():
"""Ensure behavior for passing list args"""

_proc = MetsProcessor(TEST_RES / 'k2_mets_morbio_1748529021.xml')
assert _proc.contains_group(['MAX'])

0 comments on commit c791023

Please sign in to comment.