Skip to content

Commit f1a1bea

Browse files
committed
fix
1 parent 8d60400 commit f1a1bea

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tests/test_mets.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,19 @@ def test_parse_production_pointer_file(self):
581581

582582
def assert_mets_valid(self, mets_doc, schematron=metsrw.AM_SCT_PATH):
583583
is_valid, report = metsrw.validate(mets_doc, schematron=schematron)
584-
if not is_valid:
584+
try:
585+
assert is_valid
586+
except AssertionError:
585587
raise AssertionError(report['report'])
586588

587589
def assert_pointer_valid(self, mets_doc):
588590
self.assert_mets_valid(mets_doc, schematron=metsrw.AM_PNTR_SCT_PATH)
591+
592+
593+
def test_invalid_mets_file():
594+
mets_path = 'fixtures/mets_without_groupid_in_file.xml'
595+
mets_doc = etree.parse(mets_path)
596+
schematron = metsrw.AM_SCT_PATH
597+
is_valid, report = metsrw.validate(mets_doc, schematron=schematron)
598+
assert not is_valid
599+
assert 'An amdSec element MUST contain a techMD' in report['report']

tests/test_validate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ def test_get_schematron(mocker):
2222
with pytest.raises(IOError):
2323
metsrw.get_schematron(bad_path)
2424
get_file_path.assert_called_once_with(bad_path)
25+
26+
def mockisfile(path):
27+
if path == bad_path:
28+
return False
29+
return True
30+
mocker.patch.object(os.path, 'isfile', mockisfile)
31+
with pytest.raises(IOError):
32+
metsrw.get_schematron(bad_path)
33+
assert os.path.isfile.call_count == 2

0 commit comments

Comments
 (0)