From 2dceb89d4d71646318f0b0654e4711b7d739f3eb Mon Sep 17 00:00:00 2001 From: bwmac Date: Tue, 7 May 2024 13:59:15 -0600 Subject: [PATCH] Updates testing for internal tests --- src/dcqc/tests/file_extension_test.py | 4 +++- tests/test_internal_tests.py | 31 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/dcqc/tests/file_extension_test.py b/src/dcqc/tests/file_extension_test.py index c5fafae..a9e87c9 100644 --- a/src/dcqc/tests/file_extension_test.py +++ b/src/dcqc/tests/file_extension_test.py @@ -13,6 +13,8 @@ def compute_status(self) -> TestStatus: file_extensions = file_type.file_extensions if not file.name.endswith(file_extensions): status = TestStatus.FAIL - self.failure_reason = f"{file.name} does not have one of the expected extensions ({file_extensions}) for file type: {file_type.name}" + self.failure_reason = ( + f"File extension does not match one of: {file_extensions}" + ) break return status diff --git a/tests/test_internal_tests.py b/tests/test_internal_tests.py index 9fc5603..2b8f827 100644 --- a/tests/test_internal_tests.py +++ b/tests/test_internal_tests.py @@ -52,6 +52,10 @@ def test_that_a_tiff_file_with_good_extensions_is_passed(self): def test_that_the_file_extension_test_works_on_incorrect_files(self): assert self.bad_txt_test.get_status() == TestStatus.FAIL + assert ( + self.bad_txt_test.failure_reason + == f"File extension does not match one of: {self.bad_txt_target.get_file_type().file_extensions}" + ) class Md5ChecksumTest: @@ -67,6 +71,10 @@ def test_that_the_md5_checksum_test_works_on_a_correct_file(self): def test_that_the_md5_checksum_test_works_on_incorrect_files(self): assert self.bad_txt_test.get_status() == TestStatus.FAIL + assert ( + self.bad_txt_test.failure_reason + == "Computed MD5 checksum does not match provided value" + ) class TestJsonLoadTest: @@ -82,6 +90,10 @@ def test_that_the_json_load_test_works_on_a_correct_file(self): def test_that_the_json_load_test_works_on_incorrect_files(self): assert self.good_txt_test.get_status() == TestStatus.FAIL + assert ( + self.good_txt_test.failure_reason + == "File content is unable to be loaded as JSON" + ) class TestJsonLdLoadTest: @@ -97,6 +109,10 @@ def test_that_the_jsonld_load_test_works_on_a_correct_file(self): def test_that_the_jsonld_load_test_works_on_incorrect_files(self): assert self.good_txt_test.get_status() == TestStatus.FAIL + assert ( + self.good_txt_test.failure_reason + == "File content is unable to be loaded as JSON-LD" + ) class TestPairedFastqParityTest: @@ -104,6 +120,7 @@ class TestPairedFastqParityTest: def setup_method(self, test_files): self.fastq1_file = test_files["good_fastq"] self.fastq2_file = test_files["good_compressed_fastq"] + self.good_txt_file = test_files["good_txt"] self.good_paired_target = PairedTarget([self.fastq1_file, self.fastq1_file]) self.good_paired_test = tests.PairedFastqParityTest(self.good_paired_target) self.bad_paired_target = PairedTarget([self.fastq1_file, self.fastq2_file]) @@ -114,18 +131,24 @@ def setup_method(self, test_files): self.good_compressed_paired_test = tests.PairedFastqParityTest( self.good_compressed_paired_target ) + self.good_txt_target = PairedTarget([self.good_txt_file, self.good_txt_file]) + self.good_txt_test = tests.PairedFastqParityTest(self.good_txt_target) def test_that_paired_fastq_parity_test_correctly_passes_identical_fastq_files( self, ): assert self.good_paired_test.get_status() == TestStatus.PASS - def test_that_paired_fastq_parity_test_correctly_fails_different_fastq_files( + def test_that_paired_fastq_parity_test_correctly_handles_compressed_fastq_files( self, ): - assert self.bad_paired_test.get_status() == TestStatus.FAIL + assert self.good_compressed_paired_test.get_status() == TestStatus.PASS - def test_that_paired_fastq_parity_test_correctly_handles_compressed_fastq_files( + def test_that_paired_fastq_parity_test_correctly_fails_different_fastq_files( self, ): - assert self.good_compressed_paired_test.get_status() == TestStatus.PASS + assert self.bad_paired_test.get_status() == TestStatus.FAIL + assert ( + self.bad_paired_test.failure_reason + == "FASTQ files do not have the same number of lines" + )