Exemplo n.º 1
0
def test_bar_chart_push():
    httpretty.register_uri(httpretty.POST, req_ex.DEST_URL,
                           body="OK")
    gecko_job_bar_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_BAR_CHART_CONFIG)
    gecko_job_bar_chart.push({})

    assert httpretty.has_request()
Exemplo n.º 2
0
def test__number_stat_push():
    httpretty.register_uri(httpretty.POST, req_ex.DEST_URL,
                           body="OK")
    gecko_job_number_stat = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_NUMBER_STAT_CONFIG)
    gecko_job_number_stat.push({})

    assert httpretty.has_request()
Exemplo n.º 3
0
def test_format_pie_chart_data():
    gecko_job_pie_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_PIE_CHART_CONFIG)
    pie_data = gecko_job_pie_chart.format_pie_chart_data()

    assert "data" in pie_data

    item_data = pie_data["data"]
    assert "item" in item_data
    assert len(resp_ex.GROUP_STATISTICS.get('groups')) == len(pie_data['data']['item'])
Exemplo n.º 4
0
def test_format_bar_chart_data():
    gecko_job_bar_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_BAR_CHART_CONFIG)
    bar_chart_json = gecko_job_bar_chart.format_bar_chart_data()

    assert "data" in bar_chart_json
    bar_chart_data = bar_chart_json.get("data")
    assert "x_axis" in bar_chart_data
    assert "y_axis" in bar_chart_data
    assert "series" in bar_chart_data
Exemplo n.º 5
0
def test_push():
    hosted_graphite_job = HostedGraphiteService(
        LeRestResponse(resp_ex.FULL_TIMESERIES_RESP), req_ex.SERVICE_API_KEY,
        conf_ex.SEARCH_HOSTED_GRAPHITE)
    httpretty.register_uri(httpretty.PUT, req_ex.DEST_URL, body="OK")

    hosted_graphite_job.push("payload")

    assert httpretty.has_request()
Exemplo n.º 6
0
def test_process():
    with patch.object(HostedGraphiteService, 'push',
                      return_value=None) as mock_push:
        hosted_graphite_job = HostedGraphiteService(
            LeRestResponse(resp_ex.FULL_TIMESERIES_RESP),
            req_ex.SERVICE_API_KEY, conf_ex.SEARCH_HOSTED_GRAPHITE)

        hosted_graphite_job.process()

        assert mock_push.called
Exemplo n.º 7
0
def test_convert_to_hostedgraphite_data():
    full_ts_resp_object = LeRestResponse({
        "logs": resp_ex.LOGS,
        "statistics": resp_ex.TIMESERIES_STATISTICS,
        "leql": resp_ex.LEQL
    })
    hosted_graphite_job = HostedGraphiteService(full_ts_resp_object,
                                                req_ex.SERVICE_API_KEY,
                                                conf_ex.SEARCH_HOSTED_GRAPHITE)

    hg_data = hosted_graphite_job.transform()
    pattern = re.compile("(\w+\s\d+\.\d+\s\d+\\n)+")

    assert pattern.match(hg_data)
Exemplo n.º 8
0
def test_format_number_stat_data():
    gecko_job_number_stat = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_NUMBER_STAT_CONFIG)
    number_stat = gecko_job_number_stat.format_number_stat_data()

    assert "data" in number_stat
    number_stat_data = number_stat.get("data")
    assert "item" in number_stat_data
    item = number_stat_data["item"]
    assert item[0]

    the_item = item[0]
    assert "value" in the_item
    assert the_item["value"] == 1234
    assert "text" in the_item
    assert the_item["text"] == "number_stat_text"
Exemplo n.º 9
0
def test_has_groups():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert group_obj.has_groups() is True
    assert ts_obj.has_groups() is False
Exemplo n.º 10
0
def test_get_logs():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert len(group_obj.get_logs()) == EXPECTED_LOG_KEY_COUNT
    assert len(ts_obj.get_logs()) == EXPECTED_LOG_KEY_COUNT
Exemplo n.º 11
0
def test_get_leql():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert group_obj.get_leql() == resp_ex.LEQL
    assert ts_obj.get_leql() == resp_ex.LEQL
Exemplo n.º 12
0
def test_get_data_length():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert group_obj.get_data_length() == EXPECTED_GROUP_COUNT
    assert ts_obj.get_data_length() == EXPECTED_TS_COUNT
Exemplo n.º 13
0
def test_get_count():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert group_obj.get_statistics_count() == EXPECTED_COUNT
    assert ts_obj.get_statistics_count() == EXPECTED_COUNT
Exemplo n.º 14
0
def test_get_granularity():
    group_obj = LeRestResponse(resp_ex.FULL_GROUP_RESP)
    ts_obj = LeRestResponse(resp_ex.FULL_TIMESERIES_RESP)

    assert group_obj.get_granularity() == EXPECTED_GRANULARITY
    assert ts_obj.get_granularity() == EXPECTED_GRANULARITY
Exemplo n.º 15
0
def test_number_stat_process_calls_push():
    with patch.object(GeckoboardService, 'push') as mocked_number_stat_push:
        gecko_job_number_stat = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY,
                                                  conf_ex.GECKO_NUMBER_STAT_CONFIG)
        gecko_job_number_stat.process()
        assert mocked_number_stat_push.called
Exemplo n.º 16
0
def test_format_line_chart_data():
    gecko_job_line_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_TIMESERIES_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_LINE_CHART_CONFIG)
    line_chart_data = gecko_job_line_chart.format_line_chart_data()

    assert "data" in line_chart_data
    assert line_chart_data["data"]["series"][0]["name"] == conf_ex.GECKO_LINE_CHART_CONFIG["name"]
Exemplo n.º 17
0
def test_number_stat_transform():
    with patch.object(GeckoboardService, 'transform', return_value=None) as mock_transform:
        gecko_job_number_stat = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY,
                                                  conf_ex.GECKO_NUMBER_STAT_CONFIG)
        gecko_job_number_stat.transform()
        assert mock_transform.called
Exemplo n.º 18
0
def test_bar_chart_process_calls_push():
    with patch.object(GeckoboardService, 'push') as mocked_bar_chart_push:
        gecko_job_bar_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_BAR_CHART_CONFIG)
        gecko_job_bar_chart.process()
        assert mocked_bar_chart_push.called
Exemplo n.º 19
0
def test_bar_chart_transform():
    with patch.object(GeckoboardService, 'transform', return_value=None) as mock_transform:
        gecko_job_bar_chart = GeckoboardService(LeRestResponse(resp_ex.FULL_GROUP_RESP), req_ex.SERVICE_API_KEY, conf_ex.GECKO_BAR_CHART_CONFIG)
        gecko_job_bar_chart.transform()
        assert mock_transform.called