diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 53ad200d..b9271b3d 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -39,7 +39,7 @@ jobs: cache-downloads: true post-cleanup: 'all' - name: Install PyTest - run: micromamba install pytest + run: micromamba install pytest pytest-dependency shell: bash -l {0} - name: Mamba info run: | diff --git a/test/conftest.py b/test/conftest.py index a95f8b05..94b08a1a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -16,6 +16,18 @@ 'test.svg' ] +FILES_IO = [ + 'test.txt', + 'test.tsv', + 'test.gff3', + 'test.gbff', + 'test.embl', + 'test.fna', + 'test.faa', + 'test.png', + 'test.svg' +] + SKIP_PARAMETERS = [ '--skip-tmrna', '--skip-trna', diff --git a/test/test_bakta.py b/test/test_bakta.py index 9ca62cba..a62afdc9 100644 --- a/test/test_bakta.py +++ b/test/test_bakta.py @@ -8,7 +8,7 @@ import bakta.constants as bc -from .conftest import FILES, SKIP_PARAMETERS +from .conftest import FILES, FILES_IO, SKIP_PARAMETERS def check_deepsig(): @@ -87,18 +87,19 @@ def test_bakta_plasmid(tmpdir): @pytest.mark.parametrize( 'db', [ - ('db'), # full DB + pytest.param('db', marks=pytest.mark.dependency(name="test_bakta_genome")), # full DB ('db-light') # light DB ] ) -def test_bakta_genome(db, tmpdir): +def test_bakta_genome(db, tmpdir, request): # full test on complete genome in compliant mode + output_path = Path(tmpdir).joinpath(db) proc = run( [ 'bin/bakta', '--db', f'test/{db}', '--verbose', - '--output', tmpdir, + '--output', str(output_path), '--force', '--prefix', 'test', '--min-contig-length', '200', @@ -115,13 +116,15 @@ def test_bakta_genome(db, tmpdir): ) assert proc.returncode == 0 - tmpdir_path = Path(tmpdir) for file in FILES: - output_path = tmpdir_path.joinpath(file) - assert Path.exists(output_path) - assert output_path.stat().st_size > 0 + file_path = output_path.joinpath(file) + assert Path.exists(file_path) + assert file_path.stat().st_size > 0 + + results_path = output_path.joinpath('test.json') + if(db == 'db'): + request.config.cache.set('test_bakta_json', str(results_path)) # cache for later re-usage - results_path = tmpdir_path.joinpath('test.json') results = None with results_path.open() as fh: results = json.load(fh) @@ -144,3 +147,28 @@ def test_bakta_genome(db, tmpdir): for type, count in feature_counts_expected.items(): assert len([feat for feat in features if feat['type'] == type]) == count + +@pytest.mark.dependency(depends=['test_bakta_genome']) +def test_bakta_io(tmpdir, request): + test_bakta_json = request.config.cache.get('test_bakta_json', None) + assert test_bakta_json is not None + result_path = Path(test_bakta_json) + assert Path.exists(result_path) + + output_path = Path(tmpdir) + proc = run( + [ + 'bin/bakta_io', + '--verbose', + '--output', str(output_path), + '--force', + '--prefix', 'test', + test_bakta_json + ] + ) + assert proc.returncode == 0 + + for file in FILES_IO: + file_path = output_path.joinpath(file) + assert Path.exists(file_path) + assert file_path.stat().st_size > 0