Skip to content

Commit

Permalink
Add validation test
Browse files Browse the repository at this point in the history
Also use xdist for tests
  • Loading branch information
endast committed Nov 15, 2023
1 parent 5028329 commit f885598
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ formatting: codestyle
#* Linting
.PHONY: test
test:
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=fake_vcf tests/
PYTHONPATH=$(PYTHONPATH) poetry run pytest -n auto -c pyproject.toml --cov-report=html --cov=fake_vcf tests/
poetry run coverage-badge -o assets/images/coverage.svg -f

.PHONY: check-codestyle
Expand Down
42 changes: 38 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pytest-html = "^4.1.1"
pytest-cov = "^4.1.0"
black = {version = "^23.11.0", allow-prereleases = true}
safety = "^2.3.5"
pytest-xdist = "^3.4.0"

[tool.black]
# https://github.com/psf/black
Expand Down
32 changes: 23 additions & 9 deletions tests/test_example/test_vcf_validator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import platform
import stat
import subprocess
Expand Down Expand Up @@ -52,17 +53,30 @@ def run_vcf_validator(vcf_file_path, result_path):


@pytest.mark.parametrize(
("cli_args",),
[
(["-r", "10", "--no-large-format"],),
(["-r", "50", "--no-large-format"],),
(["-r", "100", "--no-large-format"],),
(["-r", "10", "--large-format"],),
],
"cli_args",
list(
itertools.product(
*[
[["-r", f"{r}"] for r in range(1, 100, 25)],
[["-s", f"{s}"] for s in range(1, 100, 25)],
["--large-format", "--no-large-format"],
["--phased", "--no-phased"],
[[f"-c", f"chr{c}"] for c in range(1, 23)],
]
)
),
)
def test_vcf_file_validation(cli_args: list, tmp_path):
def test_vcf_file_validation(cli_args: tuple, tmp_path):
vcf_file_path = tmp_path / "example.vcf"
args = cli_args + ["-o", vcf_file_path]
args = []
for cli_arg in cli_args:
if type(cli_arg) is list:
args += cli_arg
else:
args += [cli_arg]

args += ["-o", vcf_file_path]

runner.invoke(app, args=args)

validator_status, validation_result = run_vcf_validator(
Expand Down

0 comments on commit f885598

Please sign in to comment.