def test_scalyr_function(monkeypatch, fx_function): kwargs, res, exp = fx_function read_key = '123' post = MagicMock() post.return_value.json.return_value = res monkeypatch.setattr('requests.post', post) scalyr = ScalyrWrapper(read_key) count = scalyr.function(**kwargs) assert count == exp if 'minutes' not in kwargs: kwargs['minutes'] = 5 query = get_query('timeseries', 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_function(monkeypatch, fx_function): kwargs, res, exp = fx_function read_key = '123' post = MagicMock() post.return_value.json.return_value = res monkeypatch.setattr('requests.post', post) scalyr = ScalyrWrapper(read_key) count = scalyr.function(**kwargs) assert count == exp query = get_query('numeric', kwargs['function'], read_key, **kwargs) post.assert_called_with( scalyr._ScalyrWrapper__numeric_url, json=query, headers={'Content-Type': 'application/json'})