X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fceph-volume%2Fceph_volume%2Ftests%2Fdevices%2Flvm%2Ftest_listing.py;h=efbb460f96033e46acc72885d9e6e2cf0c4afe01;hb=eafe8130898c3d7229e1c84c100c2e62e32be0d0;hp=1af1498f013514e7c3f01854f3df0de0c5dc7827;hpb=4bffc392f8d79c1ca62a89b70c9f0cd7d6b7a38f;p=ceph.git diff --git a/ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py b/ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py index 1af1498f0..efbb460f9 100644 --- a/ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py +++ b/ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py @@ -79,6 +79,23 @@ class TestList(object): with pytest.raises(SystemExit): lvm.listing.List([]).list(args) + def test_lvs_list_is_created_just_once(self, monkeypatch, is_root, volumes, factory): + api.volumes_obj_create_count = 0 + + def monkey_populate(self): + api.volumes_obj_create_count += 1 + for lv_item in api.get_api_lvs(): + self.append(api.Volume(**lv_item)) + monkeypatch.setattr(api.Volumes, '_populate', monkey_populate) + + args = factory(format='pretty', device='/dev/sda1') + with pytest.raises(SystemExit): + lvm.listing.List([]).list(args) + + # XXX: Ideally, the count should be just 1. Volumes._populate() is + # being called thrice out of which only twice is moneky_populate. + assert api.volumes_obj_create_count == 2 + class TestFullReport(object):