From 3d036588500eda8be63f0392791ff21fbea74c38 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Wed, 24 Apr 2024 08:59:01 +0200 Subject: [PATCH] Add tests --- Makefile | 2 +- tests/test_cli.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6dd5109..8a3f00d 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ publish : twine upload dist/*.tar.gz dist/*.whl coverage: - py.test --cov=toot --cov-report html tests/ + pytest --cov=twitchdl --cov-report html tests/ man: scdoc < twitch-dl.1.scd > twitch-dl.1.man diff --git a/tests/test_cli.py b/tests/test_cli.py index 5756f31..49640d4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -67,3 +67,43 @@ def test_info_not_found(runner: CliRunner): result = runner.invoke(cli.info, [""]) assert result.exit_code == 1 assert "Invalid input" in result.stderr + + +def test_download_clip(runner: CliRunner): + result = runner.invoke( + cli.download, + [ + "PoisedTalentedPuddingChefFrank", + "-q", + "source", + "--dry-run", + ], + ) + assert_ok(result) + assert ( + "Found: AGDQ Crashes during Bioshock run by GamesDoneQuick, playing BioShock (30 sec)" + in result.stdout + ) + assert ( + "Target: 2020-01-10_3099545841_gamesdonequick_agdq_crashes_during_bioshock_run.mp4" + in result.stdout + ) + assert "Dry run, clip not downloaded." in result.stdout + + +def test_download_video(runner: CliRunner): + result = runner.invoke( + cli.download, + [ + "2090131595", + "-q", + "source", + "--dry-run", + ], + ) + assert_ok(result) + assert "Found: Frost Fatales 2024 Day 1 by frozenflygone" in result.stdout + assert ( + "Output: 2024-03-14_2090131595_frozenflygone_frost_fatales_2024_day_1.mkv" in result.stdout + ) + assert "Dry run, video not downloaded." in result.stdout