Skip to content

Commit

Permalink
TST: Organise test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Aug 13, 2024
1 parent e4584f2 commit b0b2deb
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 32 deletions.
40 changes: 40 additions & 0 deletions tests/test_cli_graphbin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pathlib
import pytest

from click.testing import CliRunner

from gbintk.cli import graphbin


__author__ = "Vijini Mallawaarachchi"
__credits__ = ["Vijini Mallawaarachchi"]


DATADIR = pathlib.Path(__file__).parent / "data"

@pytest.fixture(scope="session")
def tmp_dir(tmpdir_factory):
return tmpdir_factory.mktemp("tmp")


@pytest.fixture(autouse=True)
def workingdir(tmp_dir, monkeypatch):
"""set the working directory for all tests"""
monkeypatch.chdir(tmp_dir)


@pytest.fixture(scope="session")
def runner():
"""exportrc works correctly."""
return CliRunner()


def test_graphbin_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "ESC_metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "ESC_metaSPAdes" / "contigs.fasta"
paths = DATADIR / "ESC_metaSPAdes" / "contigs.paths"
binned = DATADIR / "ESC_metaSPAdes" / "initial_binning_res.csv"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --binned {binned} --output {outpath}".split()
r = runner.invoke(graphbin, args, catch_exceptions=False)
assert r.exit_code == 0, r.output
42 changes: 42 additions & 0 deletions tests/test_cli_graphbin2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pathlib
import pytest

from click.testing import CliRunner

from gbintk.cli import graphbin2


__author__ = "Vijini Mallawaarachchi"
__credits__ = ["Vijini Mallawaarachchi"]


DATADIR = pathlib.Path(__file__).parent / "data"

@pytest.fixture(scope="session")
def tmp_dir(tmpdir_factory):
return tmpdir_factory.mktemp("tmp")


@pytest.fixture(autouse=True)
def workingdir(tmp_dir, monkeypatch):
"""set the working directory for all tests"""
monkeypatch.chdir(tmp_dir)


@pytest.fixture(scope="session")
def runner():
"""exportrc works correctly."""
return CliRunner()


def test_graphbin2_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "Sim-5G+metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "Sim-5G+metaSPAdes" / "contigs.fasta"
paths = DATADIR / "Sim-5G+metaSPAdes" / "contigs.paths"
binned = DATADIR / "Sim-5G+metaSPAdes" / "initial_contig_bins.csv"
abundance = DATADIR / "Sim-5G+metaSPAdes" / "abundance.abund"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --binned {binned} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(graphbin2, args, catch_exceptions=False)
assert r.exit_code == 0, r.output

40 changes: 40 additions & 0 deletions tests/test_cli_metacoag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pathlib
import pytest

from click.testing import CliRunner

from gbintk.cli import metacoag


__author__ = "Vijini Mallawaarachchi"
__credits__ = ["Vijini Mallawaarachchi"]


DATADIR = pathlib.Path(__file__).parent / "data"

@pytest.fixture(scope="session")
def tmp_dir(tmpdir_factory):
return tmpdir_factory.mktemp("tmp")


@pytest.fixture(autouse=True)
def workingdir(tmp_dir, monkeypatch):
"""set the working directory for all tests"""
monkeypatch.chdir(tmp_dir)


@pytest.fixture(scope="session")
def runner():
"""exportrc works correctly."""
return CliRunner()


def test_metacoag_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "Sim-5G+metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "Sim-5G+metaSPAdes" / "contigs.fasta"
paths = DATADIR / "Sim-5G+metaSPAdes" / "contigs.paths"
abundance = DATADIR / "Sim-5G+metaSPAdes" / "coverm_mean_coverage.tsv"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(metacoag, args, catch_exceptions=False)
assert r.exit_code == 0, r.output
33 changes: 1 addition & 32 deletions tests/test_cli.py → tests/test_visualise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from click.testing import CliRunner

from gbintk.cli import graphbin, graphbin2, metacoag, visualise
from gbintk.cli import visualise


__author__ = "Vijini Mallawaarachchi"
Expand All @@ -29,37 +29,6 @@ def runner():
return CliRunner()


def test_graphbin_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "ESC_metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "ESC_metaSPAdes" / "contigs.fasta"
paths = DATADIR / "ESC_metaSPAdes" / "contigs.paths"
binned = DATADIR / "ESC_metaSPAdes" / "initial_binning_res.csv"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --binned {binned} --output {outpath}".split()
r = runner.invoke(graphbin, args, catch_exceptions=False)
assert r.exit_code == 0, r.output

def test_graphbin2_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "Sim-5G+metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "Sim-5G+metaSPAdes" / "contigs.fasta"
paths = DATADIR / "Sim-5G+metaSPAdes" / "contigs.paths"
binned = DATADIR / "Sim-5G+metaSPAdes" / "initial_contig_bins.csv"
abundance = DATADIR / "Sim-5G+metaSPAdes" / "abundance.abund"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --binned {binned} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(graphbin2, args, catch_exceptions=False)
assert r.exit_code == 0, r.output

def test_metacoag_run(runner, tmp_dir):
outpath = tmp_dir
graph = DATADIR / "Sim-5G+metaSPAdes" / "assembly_graph_with_scaffolds.gfa"
contigs = DATADIR / "Sim-5G+metaSPAdes" / "contigs.fasta"
paths = DATADIR / "Sim-5G+metaSPAdes" / "contigs.paths"
abundance = DATADIR / "Sim-5G+metaSPAdes" / "coverm_mean_coverage.tsv"
args = f"--assembler spades --graph {graph} --contigs {contigs} --paths {paths} --abundance {abundance} --output {outpath}".split()
r = runner.invoke(metacoag, args, catch_exceptions=False)
assert r.exit_code == 0, r.output

def test_visualise_run(runner, tmp_dir):
outpath = tmp_dir
initial = DATADIR / "Sim-5G+metaSPAdes" / "metacoag_res.csv"
Expand Down

0 comments on commit b0b2deb

Please sign in to comment.