Exemplo n.º 1
0
def test_query_kairos_backend_gives_non_200(mock_post):
    class Shim(object):
        text = '{"errors": ["whatever", "lol"]}'
        status_code = 500
    mock_post.return_value = Shim()
    with pytest.raises(BackendQueryFailure):
        query_kairos('localhost', 8080, {'goodbye': False})
    assert mock_post.call_count == 1
Exemplo n.º 2
0
def test_query_kairos_backend_gives_non_200(mock_post):
    class Shim(object):
        text = '{"errors": ["whatever", "lol"]}'
        status_code = 500

    mock_post.return_value = Shim()
    with pytest.raises(BackendQueryFailure):
        query_kairos('localhost', 8080, {'goodbye': False})
    assert mock_post.call_count == 1
Exemplo n.º 3
0
def test_query_kairos_backend_fails_no_propagate(mock_post):
    mock_post.side_effect = requests.exceptions.RequestException
    result = query_kairos('localhost',
                          8080, {'goodbye': False},
                          propagate=False)
    assert mock_post.call_count == 1
    assert result['status_code'] == 500
    assert result['error'] == ''
Exemplo n.º 4
0
def test_query_kairos_backend_gives_non_200_no_propagate(mock_post):
    class Shim(object):
        text = '{"errors": ["whatever", "lol"]}'
        status_code = 500
    mock_post.return_value = Shim()
    result = query_kairos('localhost', 8080, {'goodbye': False}, propagate=False)
    assert result['status_code'] == 500
    assert result['error'] == 'whatever, lol'
    assert mock_post.call_count == 1
Exemplo n.º 5
0
def test_query_kairos(mock_post):
    class Shim(object):
        text = '{"hello": true}'
        status_code = 200
    mock_post.return_value = Shim()

    assert query_kairos('localhost', 8080, {'goodbye': False}) == {'hello': True}
    assert mock_post.call_count == 1
    mock_post.assert_called_once_with('http://localhost:8080/api/v1/datapoints/query',
                                      data='{"goodbye": false}')
Exemplo n.º 6
0
def test_query_kairos_backend_gives_non_200_no_propagate(mock_post):
    class Shim(object):
        text = '{"errors": ["whatever", "lol"]}'
        status_code = 500

    mock_post.return_value = Shim()
    result = query_kairos('localhost',
                          8080, {'goodbye': False},
                          propagate=False)
    assert result['status_code'] == 500
    assert result['error'] == 'whatever, lol'
    assert mock_post.call_count == 1
Exemplo n.º 7
0
def test_query_kairos(mock_post):
    class Shim(object):
        text = '{"hello": true}'
        status_code = 200

    mock_post.return_value = Shim()

    assert query_kairos('localhost', 8080, {'goodbye': False}) == {
        'hello': True
    }
    assert mock_post.call_count == 1
    mock_post.assert_called_once_with(
        'http://localhost:8080/api/v1/datapoints/query',
        data='{"goodbye": false}')
Exemplo n.º 8
0
def test_query_kairos_backend_fails_no_propagate(mock_post):
    mock_post.side_effect = requests.exceptions.RequestException
    result = query_kairos('localhost', 8080, {'goodbye': False}, propagate=False)
    assert mock_post.call_count == 1
    assert result['status_code'] == 500
    assert result['error'] == ''
Exemplo n.º 9
0
def test_query_kairos_backend_fails(mock_post):
    mock_post.side_effect = requests.exceptions.RequestException
    with pytest.raises(BackendQueryFailure):
        query_kairos('localhost', 8080, {'goodbye': False})
    assert mock_post.call_count == 1
Exemplo n.º 10
0
def test_query_kairos_backend_fails(mock_post):
    mock_post.side_effect = requests.exceptions.RequestException
    with pytest.raises(BackendQueryFailure):
        query_kairos('localhost', 8080, {'goodbye': False})
    assert mock_post.call_count == 1