def test_metrics_collector_adds_events_when_flushing_accumulated():
    mc = MockMetricsCollector()
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.flush_accumulated()

    assert len(mc.events) == 1
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
def test_metrics_collector_accumulate_same_events_into_one():
    mc = MockMetricsCollector()
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 1
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 5.0)
def test_metrics_collector_separates_different_events():
    mc = MockMetricsCollector()
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.acc_event(MetricsName.BACKUP_ORDERED_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 2
    assert (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0) in mc.events
    assert (MetricsName.BACKUP_ORDERED_BATCH_SIZE, 2.0) in mc.events
def test_metrics_collector_resets_accumulated_after_flush():
    mc = MockMetricsCollector()
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.flush_accumulated()
    mc.acc_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 2
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    assert mc.events[1] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
def test_metrics_collector_dont_add_events_when_accumulating():
    mc = MockMetricsCollector()

    mc.acc_event(gen_metrics_name(), 3.0)

    assert mc.events == []