From 1e4e241d9c77796874a003799a0546fc185c5241 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 2 Oct 2017 14:40:41 -0400 Subject: [PATCH] ceph-volume tests ensure Volume.as_dict gets populated correctly Signed-off-by: Alfredo Deza (cherry picked from commit c5b933a96d067fb8c7f753a67123e5662398f964) --- .../ceph_volume/tests/devices/lvm/test_api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_api.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_api.py index d6aa549040d76..ce99efcb0c73b 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_api.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_api.py @@ -189,6 +189,20 @@ class TestVolumes(object): with pytest.raises(exceptions.MultipleLVsError): volumes.get(lv_name='foo') + def test_as_dict_infers_type_from_tags(self, volumes): + lv_tags = "ceph.type=data,ceph.fsid=000-aaa" + osd = api.Volume(lv_name='volume1', lv_path='/dev/vg/lv', lv_tags=lv_tags) + volumes.append(osd) + result = volumes.get(lv_tags={'ceph.type': 'data'}).as_dict() + assert result['type'] == 'data' + + def test_as_dict_populates_path_from_lv_api(self, volumes): + lv_tags = "ceph.type=data,ceph.fsid=000-aaa" + osd = api.Volume(lv_name='volume1', lv_path='/dev/vg/lv', lv_tags=lv_tags) + volumes.append(osd) + result = volumes.get(lv_tags={'ceph.type': 'data'}).as_dict() + assert result['path'] == '/dev/vg/lv' + def test_find_the_correct_one(self, volumes): volume1 = api.Volume(lv_name='volume1', lv_path='/dev/vg/lv', lv_tags='') volume2 = api.Volume(lv_name='volume2', lv_path='/dev/vg/lv', lv_tags='') -- 2.39.5