def test_prepare_output_critical_verbose():
    expected = {
        'message': '2 topic(s) have replication factor lower than specified min ISR + 1.',
        'verbose': (
            "Topics:\n"
            "replication_factor=3 is lower than min_isr=3 + 1 for topic_0\n"
            "replication_factor=2 is lower than min_isr=3 + 1 for topic_1"
        ),
        'raw': {
            'topics_with_wrong_replication_factor_count': 2,
            'topics': [
                {
                    'min_isr': 3,
                    'topic': 'topic_0',
                    'replication_factor': 3,
                },
                {
                    'min_isr': 3,
                    'topic': 'topic_1',
                    'replication_factor': 2,
                }
            ],
        }
    }
    assert _prepare_output(TOPICS_WITH_WRONG_RP, True) == expected
def test_prepare_output_ok_no_verbose():
    expected = {
        'message': 'All topics have proper replication factor.',
        'raw': {
            'topics_with_wrong_replication_factor_count': 0,
        }
    }
    assert _prepare_output([], False) == expected
def test_prepare_output_critical_no_verbose():
    expected = {
        'message': '2 topic(s) have replication factor lower than specified min ISR + 1.',
        'raw': {
            'topics_with_wrong_replication_factor_count': 2,
        }
    }
    assert _prepare_output(TOPICS_WITH_WRONG_RP, False) == expected
def test_prepare_output_ok_no_verbose():
    expected = {
        'message': 'All topics have proper replication factor.',
        'raw': {
            'topics_with_wrong_replication_factor_count': 0,
        }
    }
    assert _prepare_output([], False) == expected
def test_prepare_output_critical_no_verbose():
    expected = {
        'message':
        '2 topic(s) have replication factor lower than specified min ISR + 1.',
        'raw': {
            'topics_with_wrong_replication_factor_count': 2,
        }
    }
    assert _prepare_output(TOPICS_WITH_WRONG_RP, False) == expected
def test_prepare_output_critical_verbose_with_head_limit():
    expected = {
        'message':
        '2 topic(s) have replication factor lower than specified min ISR + 1.',
        'verbose':
        ("Top 1 topics:\n"
         "replication_factor=3 is lower than min_isr=3 + 1 for topic_0"),
        'raw': {
            'topics_with_wrong_replication_factor_count':
            2,
            'topics': [
                {
                    'min_isr': 3,
                    'topic': 'topic_0',
                    'replication_factor': 3,
                },
            ],
        }
    }
    assert _prepare_output(TOPICS_WITH_WRONG_RP, True, 1) == expected