test_cli.py (1076B)
1 """Tests for CLI commands — help output and flag parsing.""" 2 3 from click.testing import CliRunner 4 5 from wrds_dl.cli import cli 6 7 8 def test_cli_help(): 9 runner = CliRunner() 10 result = runner.invoke(cli, ["--help"]) 11 assert result.exit_code == 0 12 assert "download" in result.output 13 assert "info" in result.output 14 15 16 def test_download_help(): 17 runner = CliRunner() 18 result = runner.invoke(cli, ["download", "--help"]) 19 assert result.exit_code == 0 20 for flag in ["--schema", "--table", "--columns", "--where", "--query", "--out", "--format", 21 "--limit", "--dry-run"]: 22 assert flag in result.output 23 24 25 def test_info_help(): 26 runner = CliRunner() 27 result = runner.invoke(cli, ["info", "--help"]) 28 assert result.exit_code == 0 29 for flag in ["--schema", "--table", "--json"]: 30 assert flag in result.output 31 32 33 def test_download_no_args(): 34 runner = CliRunner() 35 result = runner.invoke(cli, ["download"]) 36 assert result.exit_code != 0 37 assert "Either --query or both --schema and --table" in result.output