From 0ebb84a8d1f365a5109433f3097094c91b9d713d Mon Sep 17 00:00:00 2001 From: "yunpeng.zhang" Date: Fri, 16 Jan 2026 14:52:19 +0800 Subject: [PATCH] test: add CLI query smoke test --- tests/test_cli.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 4ca812a..25865c9 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -5,3 +5,34 @@ def test_cli_has_subcommands(): parser = build_parser() subparsers = parser._subparsers assert subparsers is not None + +from unittest.mock import patch + +from tcga_downloader.cli import main + + +def test_cli_query_writes_manifest(tmp_path, monkeypatch): + args = [ + "tcga-downloader", + "query", + "--project", + "TCGA-BRCA", + "--data-type", + "Gene Expression", + "--out", + str(tmp_path / "m.tsv"), + ] + monkeypatch.setattr("sys.argv", args) + with patch("tcga_downloader.cli.query_files") as q: + q.return_value = [ + { + "file_id": "f1", + "file_name": "a.tsv", + "data_type": "Gene Expression", + "data_format": "TSV", + "file_size": 123, + "md5sum": "abc", + } + ] + main() + assert (tmp_path / "m.tsv").exists()