コード例 #1
0
def test_client_get_domain_error(mocker, error_message, capsys):
    """Test that Client.get_domains correctly handles error response"""
    mocker.patch("tracker_client.client.get_auth_token")
    mocker.patch("tracker_client.client.create_client")
    test_client = Client()
    test_client.execute_query = mocker.MagicMock(return_value=error_message)

    with pytest.raises(ValueError, match=r"Unable to get domain foo.bar"):
        test_client.get_domain("foo.bar")

    captured = capsys.readouterr()
    assert "Server error:" in captured.out
コード例 #2
0
def test_client_get_domain(mocker, client_domain_input):
    """Test that Client.get_domain produces correct output"""
    mocker.patch("tracker_client.client.get_auth_token")
    mocker.patch("tracker_client.client.create_client")
    test_client = Client()
    test_client.execute_query = mocker.MagicMock(
        return_value=client_domain_input)

    domain = test_client.get_domain("foo.bar")

    test_client.execute_query.assert_called_once_with(queries.GET_DOMAIN,
                                                      {"domain": "foo.bar"})
    assert domain.domain_name == "foo.bar"
    assert domain.dmarc_phase == "not implemented"
    assert domain.last_ran == "2021-01-27 23:24:26.911236"
    assert domain.dkim_selectors == []