Example #1
0
def test_node_raises():
    def _check_node_raises():
        raise IgnoreResultsError()
        yield  # pylint: disable=unreachable

    assert list(make_node_notice_results("test_node",
                                         _check_node_raises())) == []
Example #2
0
def test_node_mutliline():
    node_results = (Result(state=State.WARN,
                           notice="These\nare\nfour\nlines"), )
    assert list(
        make_node_notice_results(
            "test_node", _check_function_node(node_results))) == [
                Result(
                    state=State.WARN,
                    summary="[test_node]: These, are, four, lines",
                    details=("[test_node]: These\n"
                             "[test_node]: are\n"
                             "[test_node]: four\n"
                             "[test_node]: lines"),
                ),
            ]
Example #3
0
def test_node_returns_ok_and_warn():
    node_results = _check_function_node((_OK_RESULT, _WARN_RESULT))
    assert list(make_node_notice_results("test_node", node_results)) == [
        Result(state=State.OK, notice="[test_node]: I am fine"),
        Result(state=State.WARN, notice="[test_node]: Watch out"),
    ]
Example #4
0
def test_node_returns_details_only():
    node_results = _check_function_node((Result(state=State.OK,
                                                notice="This is detailed"), ))
    assert list(make_node_notice_results("test_node", node_results)) == [
        Result(state=State.OK, notice="[test_node]: This is detailed"),
    ]
Example #5
0
def test_node_returns_metric():
    node_results = _check_function_node((_OK_RESULT, Metric("panic", 42)))
    assert list(make_node_notice_results("test_node", node_results)) == [
        Result(state=State.OK, notice="[test_node]: I am fine"),
    ]
Example #6
0
def test_node_ignore_results():
    node_results = _check_function_node((_OK_RESULT, IgnoreResults()))
    assert list(make_node_notice_results("test_node", node_results)) == []
Example #7
0
def test_node_returns_nothing():
    assert list(make_node_notice_results("test_node", _check_function_node(
        ()))) == []
    assert list(make_node_notice_results("test_node", ())) == []