Skip to content

Commit

Permalink
Updates testing for internal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed May 7, 2024
1 parent ce62791 commit 2dceb89
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/dcqc/tests/file_extension_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 27 additions & 4 deletions tests/test_internal_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -97,13 +109,18 @@ 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:
@pytest.fixture(scope="function", autouse=True)
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])
Expand All @@ -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"
)

0 comments on commit 2dceb89

Please sign in to comment.