Beispiel #1
0
def test_scalyr_timeseries_end(monkeypatch, begin_and_end):
    start, end = begin_and_end

    read_key = '123'

    post = MagicMock()
    post.return_value.json.return_value = dict({
        'status': 'success',
        'results': [{
            'values': [1]
        }]
    })

    monkeypatch.setattr('requests.post', post)

    scalyr = ScalyrWrapper(read_key)
    scalyr.timeseries('', minutes=start, end=end, align=0)

    query = get_query('facet', 'count', read_key, **{
        'minutes': start,
        'end': end,
        'align': 0
    })
    query.pop('queryType')

    final_q = {'token': query.pop('token'), 'queries': [query]}

    post.assert_called_with(scalyr._ScalyrWrapper__timeseries_url,
                            json=final_q,
                            headers={'Content-Type': 'application/json'})
Beispiel #2
0
def test_scalyr_timeseries_aligned(monkeypatch, fx_timeseries_aligned):
    kwargs, res, exp = fx_timeseries_aligned

    read_key = '123'

    post = MagicMock()
    post.return_value.json.return_value = res

    monkeypatch.setattr('requests.post', post)

    scalyr = ScalyrWrapper(read_key)
    result = scalyr.timeseries(**kwargs)

    assert result == exp

    query = get_query('facet', kwargs.get('function', 'count'), read_key,
                      **kwargs)

    query.pop('queryType')

    final_q = {'token': query.pop('token'), 'queries': [query]}

    post.assert_called_with(scalyr._ScalyrWrapper__timeseries_url,
                            json=final_q,
                            headers={'Content-Type': 'application/json'})
def test_scalyr_timeseries_aligned(monkeypatch, fx_timeseries_aligned):
    kwargs, res, exp = fx_timeseries_aligned

    read_key = '123'

    post = MagicMock()
    post.return_value.json.return_value = res

    monkeypatch.setattr('requests.post', post)

    scalyr = ScalyrWrapper(read_key)
    result = scalyr.timeseries(**kwargs)

    assert result == exp

    query = get_query('facet', kwargs.get('function', 'count'), read_key, **kwargs)

    query.pop('queryType')

    final_q = {
        'token': query.pop('token'),
        'queries': [query]
    }

    post.assert_called_with(
        scalyr._ScalyrWrapper__timeseries_url, json=final_q, headers={'Content-Type': 'application/json'})
def test_scalyr_timeseries_end(monkeypatch, begin_and_end):
    start, end = begin_and_end

    read_key = '123'

    post = MagicMock()
    post.return_value.json.return_value = dict({'status': 'success', 'results': [{'values': [1]}]})

    monkeypatch.setattr('requests.post', post)

    scalyr = ScalyrWrapper(read_key)
    scalyr.timeseries('', minutes=start, end=end, align=0)

    query = get_query('facet', 'count', read_key, **{'minutes': start, 'end': end, 'align': 0})
    query.pop('queryType')

    final_q = {
        'token': query.pop('token'),
        'queries': [query]
    }

    post.assert_called_with(
        scalyr._ScalyrWrapper__timeseries_url, json=final_q, headers={'Content-Type': 'application/json'})