from rowing_stats import cli def test_no_command_prints_usage(capsys): assert cli.main([]) == 2 out = capsys.readouterr().out for command in cli.COMMANDS: assert command in out def test_help(capsys): assert cli.main(["--help"]) == 0 assert "usage: rowing-stats" in capsys.readouterr().out def test_unknown_command(capsys): assert cli.main(["frobnicate"]) == 2 assert "unknown command 'frobnicate'" in capsys.readouterr().err def test_dispatches_to_the_subcommand(tmp_path, capsys): # An empty directory: the crop command runs and reports there is nothing to do assert cli.main(["crop", str(tmp_path)]) == 1 assert "No images found" in capsys.readouterr().err