Skip to content

Commit

Permalink
Merge pull request #41 from Sage-Bionetworks-Workflows/bwmac/orca-236…
Browse files Browse the repository at this point in the history
…/missing_external_test_coverage

[ORCA-236] Adds missing code handling and tests for external tests
  • Loading branch information
BWMac authored Jun 23, 2023
2 parents ed05233 + d06e38b commit d12968e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/dcqc/tests/bioformats_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/dcqc/tests/ome_xml_schema_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
50 changes: 50 additions & 0 deletions tests/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,63 @@ 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)
process = test.generate_process()
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
Expand Down

0 comments on commit d12968e

Please sign in to comment.