Ejemplo n.º 1
0
def success(request):
    """Return /success

    :param request: a web requeest object.
    :type request: request | None
    """
    log.info("Request for success made.")
    msgs, code = backend.success()
    return web.json_response(msgs, status=code)
Ejemplo n.º 2
0
def success(request):
    """Return /success

    :param request: a web requeest object.
    :type request: request | None
    """
    log.info("Request for success made.")
    msgs, code = backend.success()
    return web.json_response(msgs, status=code)
Ejemplo n.º 3
0
def test_success():
    mock_config = to_config({
        'master_list': ['10.0.0.1', '10.0.0.2', '10.0.0.5'],
        'agent_list': ['10.0.0.3', '10.0.0.4']
    })
    expected_output = {
        "success": "http://10.0.0.1",
        "master_count": 3,
        "agent_count": 2
    }
    expected_output_bad = {"success": "", "master_count": 0, "agent_count": 0}
    got_output, code = backend.success(mock_config)
    mock_config.update({'master_list': '', 'agent_list': ''})
    bad_out, bad_code = backend.success(mock_config)

    assert got_output == expected_output
    assert code == 200
    assert bad_out == expected_output_bad
    assert bad_code == 400
Ejemplo n.º 4
0
def test_success():
    mock_config = to_config({
        'master_list': ['10.0.0.1', '10.0.0.2', '10.0.0.5'],
        'agent_list': ['10.0.0.3', '10.0.0.4']
    })
    expected_output = {
        "success": "http://10.0.0.1",
        "master_count": 3,
        "agent_count": 2
    }
    expected_output_bad = {
        "success": "",
        "master_count": 0,
        "agent_count": 0
    }
    got_output, code = backend.success(mock_config)
    mock_config.update({'master_list': '', 'agent_list': ''})
    bad_out, bad_code = backend.success(mock_config)

    assert got_output == expected_output
    assert code == 200
    assert bad_out == expected_output_bad
    assert bad_code == 400