|
| 1 | +from unittest import mock |
| 2 | + |
1 | 3 | import click.testing as ct
|
2 | 4 |
|
3 | 5 | from bio2zarr import cli
|
4 | 6 |
|
5 |
| -# NOTE just putting things together here to see what works. |
6 |
| -# Probably want to mock the module functions here to |
7 |
| -# avoid testing any real functionality. |
8 |
| -def test_vcf_summarise(): |
9 |
| - runner = ct.CliRunner() |
10 |
| - result = runner.invoke(cli.vcf2zarr, "summarise", "filename") |
11 |
| - # FIXME not testing anything! |
| 7 | +class TestWithMocks: |
| 8 | + |
| 9 | + def test_vcf_explode(self): |
| 10 | + runner = ct.CliRunner(mix_stderr=False) |
| 11 | + with mock.patch("bio2zarr.vcf.explode") as mocked: |
| 12 | + result = runner.invoke( |
| 13 | + cli.vcf2zarr, ["explode", "source", "dest"], catch_exceptions=False |
| 14 | + |
| 15 | + ) |
| 16 | + assert result.exit_code == 0 |
| 17 | + assert len(result.stdout) == 0 |
| 18 | + assert len(result.stderr) == 0 |
| 19 | + mocked.assert_called_once_with( |
| 20 | + ("source",), |
| 21 | + "dest", |
| 22 | + column_chunk_size=64, |
| 23 | + worker_processes=1, |
| 24 | + show_progress=True, |
| 25 | + ) |
| 26 | + |
| 27 | + def test_summarise(self): |
| 28 | + runner = ct.CliRunner(mix_stderr=False) |
| 29 | + with mock.patch("bio2zarr.vcf.summarise", return_value={}) as mocked: |
| 30 | + result = runner.invoke( |
| 31 | + cli.vcf2zarr, ["summarise", "path"], catch_exceptions=False |
| 32 | + |
| 33 | + ) |
| 34 | + assert result.exit_code == 0 |
| 35 | + assert result.stdout == "\n" |
| 36 | + assert len(result.stderr) == 0 |
| 37 | + mocked.assert_called_once_with("path") |
| 38 | + |
0 commit comments