Exemplo n.º 1
0
def test_client_ok(account_creds):
    client = Client(domain=account_creds["domain"],
                    api_key=account_creds["api_key"])
    alive, error = client.health_check()

    assert alive
    assert not error
Exemplo n.º 2
0
def test_client_backoff_on_limit_reached(requests_mock):
    """Error once, check that we retry and not fail"""
    responses = [
        {
            "json": {
                "error": "limit reached"
            },
            "status_code": 429,
            "headers": {
                "Retry-After": "0"
            }
        },
        {
            "json": {
                "status": "ok"
            },
            "status_code": 200
        },
    ]
    requests_mock.register_uri("GET", "/api/v2/settings/helpdesk", responses)
    client = Client(domain="someaccount.freshdesk.com", api_key="somekey")

    result = client.settings()

    assert result == {"status": "ok"}
Exemplo n.º 3
0
def test_client_wrong_cred(account_creds):
    client = Client(domain=account_creds["domain"], api_key="wrong_key")
    alive, error = client.health_check()

    assert not alive
    assert error == "Invalid credentials"
Exemplo n.º 4
0
def test_client_wrong_account(unknown_account):
    client = Client(domain=unknown_account, api_key="wrong_key")
    alive, error = client.health_check()

    assert not alive
    assert error == "Invalid credentials"
Exemplo n.º 5
0
def test_client_wrong_domain(non_freshdesk_account):
    expected_error = "Freshdesk v2 API works only via Freshdesk domains and not via custom CNAMEs"
    with pytest.raises(AttributeError, match=expected_error):
        Client(domain=non_freshdesk_account, api_key="wrong_key")