from unittest.mock import patch import pytest from app import main @patch("app.clear_delivery_history_upcs") def test_missing_partner_id_arg_exits_with_error(mock_clear_delivery_history_upcs): with patch("sys.argv", ["app.py"]): with pytest.raises(SystemExit): main() assert not mock_clear_delivery_history_upcs.called @patch("app.clear_delivery_history_upcs") def test_clear_delivery_history_upcs_called_with_correct_args(mock_clear_delivery_history_upcs): with patch("sys.argv", ["app.py", "1", "123", "456"]): main() mock_clear_delivery_history_upcs.assert_called_once_with(1, ["123", "456"])