diff --git a/requirements/test.txt b/requirements/test.txt index 42f9503..4b19f51 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -18,3 +18,5 @@ flake8 >=3.5.0 isort pyright + +syrupy diff --git a/tests/__snapshots__/test_apps.ambr b/tests/__snapshots__/test_apps.ambr new file mode 100644 index 0000000..b85285c --- /dev/null +++ b/tests/__snapshots__/test_apps.ambr @@ -0,0 +1,65 @@ +# serializer version: 1 +# name: test_isatab2isatab + list([ + ''' + Investigation with only one study contains metadata: + ID: i_minimal + Title: Minimal Investigation + Path: i_minimal.txt + Submission Date: + Public Release Date: None + Prefer recording metadata in the study section. + ''', + ''' + Assay without platform: + Path: a_minimal.txt + Measurement Type: exome sequencing assay + Technology Type: nucleotide sequencing + Technology Platform: + ''', + 'No reference headers available for section INVESTIGATION PUBLICATIONS. Applying default order.', + 'No reference headers available for section INVESTIGATION CONTACTS. Applying default order.', + 'No reference headers available for section STUDY DESIGN DESCRIPTORS. Applying default order.', + 'No reference headers available for section STUDY PUBLICATIONS. Applying default order.', + 'No reference headers available for section STUDY FACTORS. Applying default order.', + 'No reference headers available for section STUDY CONTACTS. Applying default order.', + ]) +# --- +# name: test_isatab2isatab_input_is_output + '' +# --- +# name: test_isatab_validate + list([ + 'Incomplete ontology source; found: , Incomplete 1, 1, Incomplete 1, ()', + 'Incomplete ontology source; found: Incomplete 2, , 2, Incomplete 2, ()', + 'Ontology source name including whitespace(s); found: Incomplete 2, , 2, Incomplete 2, ()', + 'Incomplete ontology source; found: Incomplete 3, Incomplete 3, , Incomplete 3, ()', + 'Ontology source name including whitespace(s); found: Incomplete 3, Incomplete 3, , Incomplete 3, ()', + 'Incomplete ontology source; found: Incomplete 4, Incomplete 4, 4, , ()', + 'Ontology source name including whitespace(s); found: Incomplete 4, Incomplete 4, 4, , ()', + ''' + Investigation with only one study contains metadata: + ID: i_warnings + Title: Investigation with Warnings + Path: i_warnings.txt + Submission Date: + Public Release Date: None + Prefer recording metadata in the study section. + ''', + 'Invalid mail address: invalid_mail', + 'Invalid phone/fax number: CALL-ME', + 'Invalid phone/fax number: FAX-ME', + 'Invalid pubmed_id string: not-pubmed', + 'Invalid doi string: not-a-doi', + ''' + Assay without platform: + Path: a_warnings.txt + Measurement Type: exome sequencing assay + Technology Type: nucleotide sequencing + Technology Platform: + ''', + 'Assay path used more than once: a_warnings.txt', + "Found samples in assay 'a_warnings.txt' but not in parent study 's_warnings.txt':\\n0815-N2", + "Found samples in assay 'a_warnings.txt' but not in parent study 's_warnings.txt':\\n0815-N2", + ]) +# --- diff --git a/tests/test_apps.py b/tests/test_apps.py index 638a726..cec6667 100644 --- a/tests/test_apps.py +++ b/tests/test_apps.py @@ -4,6 +4,7 @@ import os.path import pytest +from syrupy.assertion import SnapshotAssertion from typer.testing import CliRunner from altamisa.apps import isatab2dot, isatab2isatab, isatab_validate @@ -12,7 +13,7 @@ runner = CliRunner() -def test_isatab_validate(): +def test_isatab_validate(snapshot: SnapshotAssertion): i_file = os.path.join(os.path.dirname(__file__), "data", "i_warnings", "i_warnings.txt") argv = ["--input-investigation-file", i_file, "--show-duplicate-warnings"] @@ -20,10 +21,10 @@ def test_isatab_validate(): result = runner.invoke(isatab_validate.app, argv) assert result.exit_code == 0 - assert 17 == len(record) + assert snapshot == [str(r.message) for r in record] -def test_isatab2isatab(tmpdir): +def test_isatab2isatab(tmpdir, snapshot: SnapshotAssertion): i_file = os.path.join(os.path.dirname(__file__), "data", "i_minimal", "i_minimal.txt") argv = [ "--input-investigation-file", @@ -38,10 +39,10 @@ def test_isatab2isatab(tmpdir): result = runner.invoke(isatab2isatab.app, argv) assert result.exit_code == 0 - assert 8 == len(record) + assert snapshot == [str(r.message) for r in record] -def test_isatab2isatab_input_is_output(tmpdir): +def test_isatab2isatab_input_is_output(tmpdir, snapshot: SnapshotAssertion): i_file = os.path.join(os.path.dirname(__file__), "data", "i_minimal", "i_minimal.txt") argv = [ "--input-investigation-file", @@ -54,7 +55,7 @@ def test_isatab2isatab_input_is_output(tmpdir): result = runner.invoke(isatab2isatab.app, argv) assert result.exit_code == 1 - assert "Can't output ISA-tab files to same directory as as input" in str(result) + assert snapshot == str(result) def test_isatab2dot(tmpdir):