Skip to content

Commit

Permalink
add more parameter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwengers committed Nov 18, 2021
1 parent 9b5701d commit a37b5b5
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 12 deletions.
137 changes: 128 additions & 9 deletions test/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
([]), # not provided
(['']), # empty
(['foo.fasta']), # not existing
(['fo o.fasta']), # not existing (whitespace)
(['test/data/invalid.fasta']) # invalid fasta DNA alphabet
]
)
Expand Down Expand Up @@ -72,6 +73,34 @@ def test_database_ok(tmpdir):
assert proc.returncode == 0


def test_output_failing():
# test database arguments
cmd_line = ['bin/bakta', '--output', '/', 'test/data/draft-w-plasmids.fna']
proc = run(cmd_line)
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--tmp-dir']) # not provided
]
)
def test_tmp_dir_failiing(parameters, tmpdir):
# test tmp dir arguments
cmd_line = ['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna']
proc = run(cmd_line)
assert proc.returncode != 0


def test_tmp_dir_ok(tmpdir):
# test tmp dir arguments

# parameter OK
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir, '--tmp-dir', ''] + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna'])
assert proc.returncode == 0


@pytest.mark.parametrize(
'parameters',
[
Expand All @@ -82,8 +111,6 @@ def test_database_ok(tmpdir):
)
def test_prodigal_tf_failiing(parameters, tmpdir):
# test prodigal training file arguments

# missing path
cmd_line = ['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna']
proc = run(cmd_line)
assert proc.returncode != 0
Expand Down Expand Up @@ -112,8 +139,6 @@ def test_prodigal_tf_ok(tmpdir):
)
def test_replicons_failiing(parameters, tmpdir):
# test replicons file arguments

# missing path
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0

Expand Down Expand Up @@ -149,8 +174,6 @@ def test_replicons_ok(tmpdir):
)
def test_proteins_failiing(parameters, tmpdir):
# test proteins file arguments

# missing path
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0

Expand All @@ -167,9 +190,87 @@ def test_proteins_ok(tmpdir):
assert Path.exists(tmpdir_path.joinpath(file))


def test_output_failing():
# test database arguments
cmd_line = ['bin/bakta', '--output', '/', 'test/data/draft-w-plasmids.fna']
@pytest.mark.parametrize(
'parameters',
[
(['--locus']), # not provided
(['--locus', '']), # empty
(['--locus', 'fo o']) # containing whitespace
]
)
def test_locus_failiing(parameters, tmpdir):
# test locus prefix arguments
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--locus-tag']), # not provided
(['--locus-tag', '']), # empty
(['--locus-tag', 'fo o']) # containing whitespace
]
)
def test_locustag_failiing(parameters, tmpdir):
# test locus-tag prefix arguments
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--genus']), # not provided
(['--genus', '']) # empty
]
)
def test_genus_failiing(parameters, tmpdir):
# test genus prefix arguments
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--species']), # not provided
(['--species', '']) # empty
]
)
def test_genus_failiing(parameters, tmpdir):
# test genus prefix arguments
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--strain']), # not provided
(['--strain', '']) # empty
]
)
def test_genus_failiing(parameters, tmpdir):
# test genus prefix arguments
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + ['test/data/NC_002127.1.fna'])
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--gram']), # not provided
(['--gram', '']), # empty
(['--gram', 'foo']), # wrong string
(['--gram', '-1']), # number
(['--gram', '0']), # number
(['--gram', '1.1']), # number
]
)
def test_threads_failing(parameters, tmpdir):
# test gram arguments
cmd_line = ['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna']
proc = run(cmd_line)
assert proc.returncode != 0

Expand Down Expand Up @@ -209,3 +310,21 @@ def test_min_contig_length_failing(parameters, tmpdir):
cmd_line = ['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna']
proc = run(cmd_line)
assert proc.returncode != 0


@pytest.mark.parametrize(
'parameters',
[
(['--translation-table']), # not provided
(['--translation-table', '']), # empty
(['--translation-table', 'foo']), # string
(['--translation-table', '-1']), # smaller than zero
(['--translation-table', '0']), # zero
(['--translation-table', '1.1']), # float
]
)
def test_min_contig_length_failing(parameters, tmpdir):
# test min-contig-length arguments
cmd_line = ['bin/bakta', '--db', 'test/db', '--output', tmpdir] + parameters + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna']
proc = run(cmd_line)
assert proc.returncode != 0
6 changes: 3 additions & 3 deletions test/test_bakta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@pytest.mark.slow
def test_bakta_mock_skipped_features(tmpdir):
# fast test skipping all feature detections
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir, '--prefix', 'test', '--proteins', 'test/data/user-proteins.faa'] + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna'])
proc = run(['bin/bakta', '--db', 'test/db', '--output', tmpdir, '--tmp-dir', tmpdir, '--prefix', 'test', '--min-contig-length', '200', '--proteins', 'test/data/user-proteins.faa', '--genus', 'Foo gen. nov.', '--species', 'bar sp. nov.', '--strain', 'test 1'] + SKIP_PARAMETERS + ['test/data/NC_002127.1.fna'])
assert proc.returncode == 0

tmpdir_path = Path(tmpdir)
Expand All @@ -20,7 +20,7 @@ def test_bakta_mock_skipped_features(tmpdir):
@pytest.mark.slow
def test_bakta_plasmid(tmpdir):
# full test on plasmid
proc = run(['bin/bakta', '--db', 'test/db', '--verbose', '--output', tmpdir, '--prefix', 'test', '--complete', '--proteins', 'test/data/user-proteins.faa', 'test/data/NC_002127.1.fna'])
proc = run(['bin/bakta', '--db', 'test/db', '--verbose', '--output', tmpdir, '--tmp-dir', tmpdir, '--prefix', 'test', '--min-contig-length', '200', '--complete', '--proteins', 'test/data/user-proteins.faa', '--genus', 'Foo gen. nov.', '--species', 'bar sp. nov.', '--strain', 'test 1', 'test/data/NC_002127.1.fna'])
assert proc.returncode == 0

tmpdir_path = Path(tmpdir)
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_bakta_plasmid(tmpdir):
@pytest.mark.slow
def test_bakta_genome(tmpdir):
# full test on complete genome in compliant mode
proc = run(['bin/bakta', '--db', 'test/db', '--verbose', '--output', tmpdir, '--prefix', 'test', '--complete', '--compliant', '--proteins', 'test/data/user-proteins.faa', 'test/data/GCF_000008865.2.fna.gz'])
proc = run(['bin/bakta', '--db', 'test/db', '--verbose', '--output', tmpdir, '--tmp-dir', tmpdir, '--prefix', 'test', '--min-contig-length', '200', '--complete', '--compliant', '--proteins', 'test/data/user-proteins.faa', '--genus', 'Foo gen. nov.', '--species', 'bar sp. nov.', '--strain', 'test 1', 'test/data/GCF_000008865.2.fna.gz'])
assert proc.returncode == 0

tmpdir_path = Path(tmpdir)
Expand Down

0 comments on commit a37b5b5

Please sign in to comment.