File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -581,8 +581,19 @@ def test_parse_production_pointer_file(self):
581
581
582
582
def assert_mets_valid (self , mets_doc , schematron = metsrw .AM_SCT_PATH ):
583
583
is_valid , report = metsrw .validate (mets_doc , schematron = schematron )
584
- if not is_valid :
584
+ try :
585
+ assert is_valid
586
+ except AssertionError :
585
587
raise AssertionError (report ['report' ])
586
588
587
589
def assert_pointer_valid (self , mets_doc ):
588
590
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' ]
Original file line number Diff line number Diff line change @@ -22,3 +22,12 @@ def test_get_schematron(mocker):
22
22
with pytest .raises (IOError ):
23
23
metsrw .get_schematron (bad_path )
24
24
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
You can’t perform that action at this time.
0 commit comments