def test_unsilencer_reports_when_not_found(mocker, capsys): mocker.patch("unsilencer.validate_email", return_value=True) mocker.patch("unsilencer.check_if_listed", return_value=[]) unsilencer.unsilence("*****@*****.**") captured = capsys.readouterr() assert captured.out == "[email protected] does not appear on any suppression list.\n"
def test_unsilencer_exits_when_email_is_invalid(mocker, capsys): mocker.patch("unsilencer.validate_email", return_value=False) with pytest.raises(SystemExit) as pytest_wrapped_e: unsilencer.unsilence("invalid-email") captured = capsys.readouterr() assert (captured.out == "The input does not appear to be a valid email address, bye!\n") assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1
def test_unsilencer_reports_when_found(mocker, capsys): mocker.patch("unsilencer.validate_email", return_value=True) mocker.patch("unsilencer.check_if_listed", return_value=["bounces"]) mocker.patch("unsilencer.remove_from_list") unsilencer.unsilence("*****@*****.**") captured = capsys.readouterr() assert (captured.out == "Email address: [email protected] is listed on these lists:\n" "\tbounces\n" "Removing user from list now!!\n")