def test_combine_disks(disks): combined_disk = diskstat.combine_disks(disks) # any key found in at least one of the input dicts must be present in the combination assert sorted(combined_disk) == sorted(set(sum((list(disk) for disk in disks), []))) for key, val in combined_disk.items(): exp_res = sum(disk.get(key, 0.) for disk in disks) if key.startswith("ave") or key in ("utilization", "latency", "queue_length"): assert val == exp_res / sum(key in disk for disk in disks) else: assert val == exp_res
def test_summarize_disks(disks): assert diskstat.summarize_disks( ("a", disk) for disk in disks) == diskstat.combine_disks(disks) assert diskstat.summarize_disks( ("LVM " if i == 0 else "b", disk) for i, disk in enumerate(disks)) == diskstat.combine_disks(disks[1:])
def test_summarize_disks(disks): assert diskstat.summarize_disks( ('a', disk) for disk in disks) == diskstat.combine_disks(disks) assert diskstat.summarize_disks( ('LVM ' if i == 0 else 'b', disk) for i, disk in enumerate(disks)) == diskstat.combine_disks(disks[1:])
def test_combine_disks( disks_to_combine: Iterable[diskstat.Disk], expected_result: diskstat.Disk, ) -> None: assert diskstat.combine_disks(disks_to_combine) == expected_result