from unittest.mock import patch import pytest import app def test_missing_youtube_video_id_argument(): with patch("sys.argv", ["app.py"]): with pytest.raises(SystemExit): app.main() def test_correct_args_passed_to_clear_bacon_history(): with patch("sys.argv", ["app.py", "--ids", "BQPxgsLX2PM,Gx_8z-IufPg"]): with patch("app.clear_bacon_history") as mock_clear: app.main() mock_clear.assert_called_once_with(["BQPxgsLX2PM", "Gx_8z-IufPg"]) def test_ids_starting_with_dash_are_accepted(): with patch("sys.argv", ["app.py", "--ids", "-abc123,-def456"]): with patch("app.clear_bacon_history") as mock_clear: app.main() mock_clear.assert_called_once_with(["-abc123", "-def456"])