Skip to content

Commit d12968e

Browse files
authored
Merge pull request #41 from Sage-Bionetworks-Workflows/bwmac/orca-236/missing_external_test_coverage
[ORCA-236] Adds missing code handling and tests for external tests
2 parents ed05233 + d06e38b commit d12968e

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

src/dcqc/tests/bioformats_info_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44

55
class BioFormatsInfoTest(ExternalBaseTest):
66
tier = 2
7+
pass_code = "0"
78
target: SingleTarget
89

910
def generate_process(self) -> Process:
1011
path = self.target.file.stage()
12+
string_path = self._short_string_path(path, "dcqc-staged-")
13+
1114
command_args = [
1215
"/opt/bftools/showinf",
1316
"-nopix",
1417
"-novalid",
1518
"-nocore",
16-
path,
19+
string_path,
1720
]
1821
process = Process(
1922
container="quay.io/sagebionetworks/bftools:latest",

src/dcqc/tests/ome_xml_schema_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
class OmeXmlSchemaTest(ExternalBaseTest):
66
tier = 2
7+
pass_code = "0"
78
target: SingleTarget
89

910
def generate_process(self) -> Process:
1011
path = self.target.file.stage()
12+
string_path = self._short_string_path(path, "dcqc-staged-")
13+
1114
command_args = [
1215
"/opt/bftools/xmlvalid",
13-
path,
16+
string_path,
1417
]
1518
process = Process(
1619
container="quay.io/sagebionetworks/bftools:latest",

tests/test_tests.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,63 @@ def test_that_the_bioformats_info_test_command_is_produced(test_targets):
126126
assert "showinf" in process.command
127127

128128

129+
def test_that_the_bioformats_info_test_correctly_interprets_exit_code_0_and_1(
130+
test_files, mocker
131+
):
132+
# 0 is pass, 1 is fail
133+
tiff_file = test_files["tiff"]
134+
target = SingleTarget(tiff_file)
135+
with TemporaryDirectory() as tmp_dir:
136+
path_0 = Path(tmp_dir, "code_0.txt")
137+
path_1 = Path(tmp_dir, "code_1.txt")
138+
path_0.write_text("0")
139+
path_1.write_text("1")
140+
pass_outputs = {"std_out": path_1, "std_err": path_1, "exit_code": path_0}
141+
fail_outputs = {"std_out": path_0, "std_err": path_0, "exit_code": path_1}
142+
143+
test = tests.BioFormatsInfoTest(target)
144+
mocker.patch.object(test, "_find_process_outputs", return_value=pass_outputs)
145+
test_status = test.get_status()
146+
assert test_status == TestStatus.PASS
147+
148+
test = tests.BioFormatsInfoTest(target)
149+
mocker.patch.object(test, "_find_process_outputs", return_value=fail_outputs)
150+
test_status = test.get_status()
151+
assert test_status == TestStatus.FAIL
152+
153+
129154
def test_that_the_ome_xml_schema_test_command_is_produced(test_targets):
130155
target = test_targets["tiff"]
131156
test = tests.OmeXmlSchemaTest(target)
132157
process = test.generate_process()
133158
assert "xmlvalid" in process.command
134159

135160

161+
def test_that_the_ome_xml_info_test_correctly_interprets_exit_code_0_and_1(
162+
test_files, mocker
163+
):
164+
# 0 is pass, 1 is fail
165+
tiff_file = test_files["tiff"]
166+
target = SingleTarget(tiff_file)
167+
with TemporaryDirectory() as tmp_dir:
168+
path_0 = Path(tmp_dir, "code_0.txt")
169+
path_1 = Path(tmp_dir, "code_1.txt")
170+
path_0.write_text("0")
171+
path_1.write_text("1")
172+
pass_outputs = {"std_out": path_1, "std_err": path_1, "exit_code": path_0}
173+
fail_outputs = {"std_out": path_0, "std_err": path_0, "exit_code": path_1}
174+
175+
test = tests.OmeXmlSchemaTest(target)
176+
mocker.patch.object(test, "_find_process_outputs", return_value=pass_outputs)
177+
test_status = test.get_status()
178+
assert test_status == TestStatus.PASS
179+
180+
test = tests.OmeXmlSchemaTest(target)
181+
mocker.patch.object(test, "_find_process_outputs", return_value=fail_outputs)
182+
test_status = test.get_status()
183+
assert test_status == TestStatus.FAIL
184+
185+
136186
def test_that_the_md5_checksum_test_can_be_retrieved_by_name():
137187
test = BaseTest.get_subclass_by_name("Md5ChecksumTest")
138188
assert test is tests.Md5ChecksumTest

0 commit comments

Comments
 (0)