Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwdunham committed Nov 11, 2017
1 parent 8d60400 commit f1a1bea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,19 @@ def test_parse_production_pointer_file(self):

def assert_mets_valid(self, mets_doc, schematron=metsrw.AM_SCT_PATH):
is_valid, report = metsrw.validate(mets_doc, schematron=schematron)
if not is_valid:
try:
assert is_valid
except AssertionError:
raise AssertionError(report['report'])

def assert_pointer_valid(self, mets_doc):
self.assert_mets_valid(mets_doc, schematron=metsrw.AM_PNTR_SCT_PATH)


def test_invalid_mets_file():
mets_path = 'fixtures/mets_without_groupid_in_file.xml'
mets_doc = etree.parse(mets_path)
schematron = metsrw.AM_SCT_PATH
is_valid, report = metsrw.validate(mets_doc, schematron=schematron)
assert not is_valid
assert 'An amdSec element MUST contain a techMD' in report['report']
9 changes: 9 additions & 0 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ def test_get_schematron(mocker):
with pytest.raises(IOError):
metsrw.get_schematron(bad_path)
get_file_path.assert_called_once_with(bad_path)

def mockisfile(path):
if path == bad_path:
return False
return True
mocker.patch.object(os.path, 'isfile', mockisfile)
with pytest.raises(IOError):
metsrw.get_schematron(bad_path)
assert os.path.isfile.call_count == 2

0 comments on commit f1a1bea

Please sign in to comment.