Skip to content

Commit

Permalink
test_ocrd_mets: tests in docker have OCRD_METS_CACHING=1 always, unset
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Jul 16, 2024
1 parent 6136d9c commit 1634d3f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/model/test_ocrd_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def test_unique_identifier_from_nothing():


def test_str():
mets = OcrdMets(content='<mets/>', cache_flag=False)
assert str(mets) == 'OcrdMets[cached=False,fileGrps=[],files=[]]'
mets_cached = OcrdMets(content='<mets/>', cache_flag=True)
assert str(mets_cached) == 'OcrdMets[cached=True,fileGrps=[],files=[]]'
with temp_env_var('OCRD_METS_CACHING', None):
mets = OcrdMets(content='<mets/>', cache_flag=False)
assert str(mets) == 'OcrdMets[cached=False,fileGrps=[],files=[]]'
mets_cached = OcrdMets(content='<mets/>', cache_flag=True)
assert str(mets_cached) == 'OcrdMets[cached=True,fileGrps=[],files=[]]'


def test_file_groups(sbb_sample_01):
Expand Down Expand Up @@ -383,12 +384,15 @@ def test_invalid_filegrp():
@contextmanager
def temp_env_var(k, v):
v_before = environ.get(k, None)
environ[k] = v
if v == None:
environ.pop(k, None)
else:
environ[k] = v
yield
if v_before is not None:
environ[k] = v_before
else:
del environ[k]
environ.pop(k, None)

def test_envvar():
assert OcrdMets(filename=assets.url_of('SBB0000F29300010000/data/mets.xml'), cache_flag=True)._cache_flag
Expand Down

0 comments on commit 1634d3f

Please sign in to comment.