Skip to content

Commit dbd8e1d

Browse files
Pad out basic cli testing
1 parent ff7ed5a commit dbd8e1d

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

bio2zarr/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,14 @@ def encode(if_path, zarr_path, verbose, schema, worker_processes):
8585
@worker_processes
8686
def convert_vcf(vcfs, out_path, verbose, worker_processes):
8787
setup_logging(verbose)
88-
vcf.convert(
89-
vcfs, out_path, show_progress=True, worker_processes=worker_processes
90-
)
88+
vcf.convert(vcfs, out_path, show_progress=True, worker_processes=worker_processes)
9189

9290

9391
@click.command
9492
@click.argument("vcfs", nargs=-1, required=True)
9593
@click.argument("out_path", type=click.Path())
9694
def validate(vcfs, out_path):
95+
# FIXME! Will silently not look at remaining VCFs
9796
vcf.validate(vcfs[0], out_path, show_progress=True)
9897

9998

bio2zarr/vcf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,9 @@ def asjson(self):
923923
@staticmethod
924924
def fromdict(d):
925925
ret = ZarrConversionSpec(**d)
926-
ret.columns = {key: ZarrColumnSpec(**value) for key,value in d["columns"].items()}
926+
ret.columns = {
927+
key: ZarrColumnSpec(**value) for key, value in d["columns"].items()
928+
}
927929
return ret
928930

929931
@staticmethod
@@ -1326,9 +1328,7 @@ def mkschema(if_path, out):
13261328
out.write(spec.asjson())
13271329

13281330

1329-
def encode(
1330-
if_path, zarr_path, schema_path, worker_processes=1, show_progress=False
1331-
):
1331+
def encode(if_path, zarr_path, schema_path, worker_processes=1, show_progress=False):
13321332
pcvcf = PickleChunkedVcf.load(if_path)
13331333
if schema_path is None:
13341334
schema = ZarrConversionSpec.generate(pcvcf)

tests/test_cli.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ def test_encode(self):
6565
show_progress=True,
6666
)
6767

68-
def test_convert(self):
68+
def test_convert_vcf(self):
6969
runner = ct.CliRunner(mix_stderr=False)
7070
with mock.patch("bio2zarr.vcf.convert") as mocked:
7171
result = runner.invoke(
72-
cli.vcf2zarr, ["convert", "vcf_path", "zarr_path"], catch_exceptions=False
72+
cli.vcf2zarr,
73+
["convert", "vcf_path", "zarr_path"],
74+
catch_exceptions=False,
7375
)
7476
assert result.exit_code == 0
7577
assert len(result.stdout) == 0
@@ -80,3 +82,38 @@ def test_convert(self):
8082
worker_processes=1,
8183
show_progress=True,
8284
)
85+
86+
def test_validate(self):
87+
runner = ct.CliRunner(mix_stderr=False)
88+
with mock.patch("bio2zarr.vcf.validate") as mocked:
89+
result = runner.invoke(
90+
cli.vcf2zarr,
91+
["validate", "vcf_path", "zarr_path"],
92+
catch_exceptions=False,
93+
)
94+
assert result.exit_code == 0
95+
assert len(result.stdout) == 0
96+
assert len(result.stderr) == 0
97+
mocked.assert_called_once_with(
98+
"vcf_path",
99+
"zarr_path",
100+
show_progress=True,
101+
)
102+
103+
def test_convert_plink(self):
104+
runner = ct.CliRunner(mix_stderr=False)
105+
with mock.patch("bio2zarr.plink.convert") as mocked:
106+
result = runner.invoke(
107+
cli.plink2zarr, ["convert", "in", "out"], catch_exceptions=False
108+
)
109+
assert result.exit_code == 0
110+
assert len(result.stdout) == 0
111+
assert len(result.stderr) == 0
112+
mocked.assert_called_once_with(
113+
"in",
114+
"out",
115+
worker_processes=1,
116+
chunk_width=None,
117+
chunk_length=None,
118+
show_progress=True,
119+
)

0 commit comments

Comments
 (0)