Skip to content

Commit b9e5f8b

Browse files
Fixup CLI tests
1 parent 4f94fef commit b9e5f8b

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

tests/test_cli.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
compressor=None,
1515
worker_processes=1,
1616
show_progress=True,
17-
local_alleles=False,
1817
)
1918

2019
DEFAULT_DEXPLODE_PARTITION_ARGS = dict()
@@ -24,7 +23,6 @@
2423
column_chunk_size=64,
2524
compressor=None,
2625
show_progress=True,
27-
local_alleles=False,
2826
)
2927

3028
DEFAULT_ENCODE_ARGS = dict(
@@ -49,6 +47,12 @@
4947

5048
DEFAULT_DENCODE_FINALISE_ARGS = dict(show_progress=True)
5149

50+
DEFAULT_MKSHCHEMA_ARGS = dict(
51+
variants_chunk_size=None,
52+
samples_chunk_size=None,
53+
local_alleles=False,
54+
)
55+
5256
DEFAULT_CONVERT_ARGS = dict(
5357
variants_chunk_size=None,
5458
samples_chunk_size=None,
@@ -297,29 +301,6 @@ def test_vcf_explode_missing_and_existing_vcf(self, mocked, tmp_path):
297301
assert "'no_such_file' does not exist" in result.stderr
298302
mocked.assert_not_called()
299303

300-
@pytest.mark.parametrize("local_alleles", [False, True])
301-
@mock.patch("bio2zarr.vcf2zarr.explode")
302-
def test_vcf_explode_local_alleles(self, mocked, tmp_path, local_alleles):
303-
icf_path = tmp_path / "icf"
304-
runner = ct.CliRunner(mix_stderr=False)
305-
306-
if local_alleles:
307-
local_alleles_flag = "--local-alleles"
308-
else:
309-
local_alleles_flag = "--no-local-alleles"
310-
311-
result = runner.invoke(
312-
cli.vcf2zarr_main,
313-
f"explode {self.vcf_path} {icf_path} {local_alleles_flag}",
314-
catch_exceptions=False,
315-
)
316-
assert result.exit_code == 0
317-
assert len(result.stdout) == 0
318-
assert len(result.stderr) == 0
319-
args = dict(DEFAULT_EXPLODE_ARGS)
320-
args["local_alleles"] = local_alleles
321-
mocked.assert_called_once_with(str(icf_path), (self.vcf_path,), **args)
322-
323304
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
324305
@mock.patch("bio2zarr.vcf2zarr.explode_init", return_value=FakeWorkSummary(5))
325306
def test_vcf_dexplode_init(self, mocked, tmp_path, progress, flag):
@@ -462,7 +443,7 @@ def test_mkschema(self, mocked, tmp_path):
462443
runner = ct.CliRunner(mix_stderr=False)
463444
result = runner.invoke(
464445
cli.vcf2zarr_main,
465-
f"mkschema {tmp_path} --variants-chunk-size=3 " "--samples-chunk-size=4",
446+
f"mkschema {tmp_path} --variants-chunk-size=3 --samples-chunk-size=4",
466447
catch_exceptions=False,
467448
)
468449
assert result.exit_code == 0
@@ -726,6 +707,29 @@ def test_mkschema(self, tmp_path):
726707
assert d["samples_chunk_size"] == 2
727708
assert d["variants_chunk_size"] == 3
728709

710+
@pytest.mark.parametrize("local_alleles", [False, True])
711+
def test_mkschema_local_alleles(self, tmp_path, local_alleles):
712+
icf_path = tmp_path / "icf"
713+
local_alleles_flag = {True: "--local-alleles", False: "--no-local-alleles"}[
714+
local_alleles
715+
]
716+
runner = ct.CliRunner(mix_stderr=False)
717+
result = runner.invoke(
718+
cli.vcf2zarr_main,
719+
f"explode {self.vcf_path} {icf_path}",
720+
catch_exceptions=False,
721+
)
722+
assert result.exit_code == 0
723+
result = runner.invoke(
724+
cli.vcf2zarr_main,
725+
f"mkschema {icf_path} {local_alleles_flag}",
726+
catch_exceptions=False,
727+
)
728+
assert result.exit_code == 0
729+
d = json.loads(result.stdout)
730+
call_LA_exists = "call_LA" in [f["name"] for f in d["fields"]]
731+
assert call_LA_exists == local_alleles
732+
729733
def test_encode(self, tmp_path):
730734
icf_path = tmp_path / "icf"
731735
zarr_path = tmp_path / "zarr"

0 commit comments

Comments
 (0)