Exemple #1
0
def test_checker_summary_print_status(patches):
    checker = DummyChecker()
    summary = CheckerSummary(checker)
    patched = patches("CheckerSummary._section", prefix="tools.base.checker")

    summary.checker = MagicMock()
    with patched as (m_section, ):
        m_section.return_value = ["A", "B", "C"]
        summary.print_status()
    assert (list(m_section.call_args) == [
        (f"[SUMMARY:{summary.checker.name}] {summary.checker.status}", ), {}
    ])
    assert (list(summary.checker.log.warning.call_args) == [('A\nB\nC', ), {}])
Exemple #2
0
def test_checker_summary_print_status(patches, errors, warnings):
    checker = DummyChecker()
    summary = CheckerSummary(checker)
    summary.checker = MagicMock()
    summary.checker.errors = errors
    summary.checker.warnings = warnings

    assert not summary.print_status()

    if errors:
        assert (list(summary.checker.log.error.call_args) == [
            (f"{summary.checker.status}", ), {}
        ])
        assert not summary.checker.log.warning.called
        assert not summary.checker.log.info.called
        return

    if warnings:
        assert (list(summary.checker.log.warning.call_args) == [
            (f"{summary.checker.status}", ), {}
        ])
        assert not summary.checker.log.error.called
        assert not summary.checker.log.info.called
        return

    assert (list(summary.checker.log.info.call_args) == [
        (f"{summary.checker.status}", ), {}
    ])
    assert not summary.checker.log.error.called
    assert not summary.checker.log.warning.called