예제 #1
0
def test_get_metrics(http_client, base_url, mocker):

    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'metrics'))

    assert response.code == 200
    assert json.loads(response.body) == TEST_METRICS
예제 #2
0
def test_distribution_none(http_client, base_url):
    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'distribution/none'))

    assert response.code == 200
    assert json.loads(response.body) == dict(
        app0=0,
        app4=0,
        app8=0,
    )
예제 #3
0
def test_get_metrics_flatten(http_client, base_url, mocker):

    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'metrics') + '?flatten')

    metrics = json.loads(response.body)

    assert response.code == 200

    assert metrics == dict(flatten_dict(TEST_METRICS))
    assert metrics == dict(flatten_dict_rec(TEST_METRICS))
예제 #4
0
파일: test_web.py 프로젝트: shaitan/burlak
def test_filter_handle(http_client, base_url):
    response = yield http_client.fetch(base_url +
                                       make_url('', API_V1, r'filter'))

    assert response.code == 200

    cf = json.loads(response.body)
    cf = cf.get('control_filter', dict())

    assert ControlFilter.from_dict(cf) == \
        test_filter
예제 #5
0
def test_incoming_state(http_client, base_url):
    response = yield http_client.fetch(
        base_url + make_url('', API_V1, 'incoming_state'))

    in_state = json.loads(response.body)

    assert response.code == 200
    assert in_state.get('state', {}) == {
        k: v._asdict() for k, v in incoming_state.iteritems()
    }

    assert in_state.get('version', -1) == TEST_INCOMING_STATE_VERSION
    assert in_state.get('timestamp', -1) == TEST_TS
예제 #6
0
def test_distribution_some(http_client, base_url):
    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'distribution/some'))

    assert response.code == 200
    assert json.loads(response.body) == dict(
        app1=1,
        app2=2,
        app3=3,
        app5=1,
        app6=2,
        app7=3,
        app9=1,
    )
예제 #7
0
def test_defaults_channels(http_client, base_url):
    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'channels'))

    assert response.code == 200
    assert json.loads(response.body) == dict(apps=test_channels)
예제 #8
0
    response = yield http_client.fetch(
        base_url + make_url('', API_V1, r'metrics') + '?flatten')

    metrics = json.loads(response.body)

    assert response.code == 200

    assert metrics == dict(flatten_dict(TEST_METRICS))
    assert metrics == dict(flatten_dict_rec(TEST_METRICS))


@pytest.mark.parametrize(
    'is_legacy, state_path',
    [
        (True, r'/state'),
        (False, make_url('', API_V1, r'state')),
    ]
)
@pytest.mark.gen_test
def test_get_state(http_client, base_url, is_legacy, state_path):
    response = yield http_client.fetch(
        base_url + state_path)

    loaded_state = json.loads(response.body)

    state = loaded_state if is_legacy else loaded_state.get('state', {})

    assert response.code == 200
    assert state == \
        {app: record._asdict() for app, record in test_state.iteritems()}