diff --git a/src/dcqc/tests/bioformats_info_test.py b/src/dcqc/tests/bioformats_info_test.py index 25b8ef5..382aa56 100644 --- a/src/dcqc/tests/bioformats_info_test.py +++ b/src/dcqc/tests/bioformats_info_test.py @@ -4,16 +4,19 @@ class BioFormatsInfoTest(ExternalBaseTest): tier = 2 + pass_code = "0" target: SingleTarget def generate_process(self) -> Process: path = self.target.file.stage() + string_path = self._short_string_path(path, "dcqc-staged-") + command_args = [ "/opt/bftools/showinf", "-nopix", "-novalid", "-nocore", - path, + string_path, ] process = Process( container="quay.io/sagebionetworks/bftools:latest", diff --git a/src/dcqc/tests/ome_xml_schema_test.py b/src/dcqc/tests/ome_xml_schema_test.py index 4d2a6c5..48283d9 100644 --- a/src/dcqc/tests/ome_xml_schema_test.py +++ b/src/dcqc/tests/ome_xml_schema_test.py @@ -4,13 +4,16 @@ class OmeXmlSchemaTest(ExternalBaseTest): tier = 2 + pass_code = "0" target: SingleTarget def generate_process(self) -> Process: path = self.target.file.stage() + string_path = self._short_string_path(path, "dcqc-staged-") + command_args = [ "/opt/bftools/xmlvalid", - path, + string_path, ] process = Process( container="quay.io/sagebionetworks/bftools:latest", diff --git a/tests/test_tests.py b/tests/test_tests.py index 865a901..cb34feb 100644 --- a/tests/test_tests.py +++ b/tests/test_tests.py @@ -126,6 +126,31 @@ def test_that_the_bioformats_info_test_command_is_produced(test_targets): assert "showinf" in process.command +def test_that_the_bioformats_info_test_correctly_interprets_exit_code_0_and_1( + test_files, mocker +): + # 0 is pass, 1 is fail + tiff_file = test_files["tiff"] + target = SingleTarget(tiff_file) + with TemporaryDirectory() as tmp_dir: + path_0 = Path(tmp_dir, "code_0.txt") + path_1 = Path(tmp_dir, "code_1.txt") + path_0.write_text("0") + path_1.write_text("1") + pass_outputs = {"std_out": path_1, "std_err": path_1, "exit_code": path_0} + fail_outputs = {"std_out": path_0, "std_err": path_0, "exit_code": path_1} + + test = tests.BioFormatsInfoTest(target) + mocker.patch.object(test, "_find_process_outputs", return_value=pass_outputs) + test_status = test.get_status() + assert test_status == TestStatus.PASS + + test = tests.BioFormatsInfoTest(target) + mocker.patch.object(test, "_find_process_outputs", return_value=fail_outputs) + test_status = test.get_status() + assert test_status == TestStatus.FAIL + + def test_that_the_ome_xml_schema_test_command_is_produced(test_targets): target = test_targets["tiff"] test = tests.OmeXmlSchemaTest(target) @@ -133,6 +158,31 @@ def test_that_the_ome_xml_schema_test_command_is_produced(test_targets): assert "xmlvalid" in process.command +def test_that_the_ome_xml_info_test_correctly_interprets_exit_code_0_and_1( + test_files, mocker +): + # 0 is pass, 1 is fail + tiff_file = test_files["tiff"] + target = SingleTarget(tiff_file) + with TemporaryDirectory() as tmp_dir: + path_0 = Path(tmp_dir, "code_0.txt") + path_1 = Path(tmp_dir, "code_1.txt") + path_0.write_text("0") + path_1.write_text("1") + pass_outputs = {"std_out": path_1, "std_err": path_1, "exit_code": path_0} + fail_outputs = {"std_out": path_0, "std_err": path_0, "exit_code": path_1} + + test = tests.OmeXmlSchemaTest(target) + mocker.patch.object(test, "_find_process_outputs", return_value=pass_outputs) + test_status = test.get_status() + assert test_status == TestStatus.PASS + + test = tests.OmeXmlSchemaTest(target) + mocker.patch.object(test, "_find_process_outputs", return_value=fail_outputs) + test_status = test.get_status() + assert test_status == TestStatus.FAIL + + def test_that_the_md5_checksum_test_can_be_retrieved_by_name(): test = BaseTest.get_subclass_by_name("Md5ChecksumTest") assert test is tests.Md5ChecksumTest