mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmdbustest: Add test for property "Get"
We typically use "GetAll", so add test for "Get" and check values.
This commit is contained in:
parent
01ef2f2525
commit
d0f94e763d
@ -677,6 +677,20 @@ class TestDbusService(unittest.TestCase):
|
|||||||
EOD), vg, LV_BASE_INT)
|
EOD), vg, LV_BASE_INT)
|
||||||
self._validate_lookup("%s/%s" % (vg.Name, lv_name), lv.object_path)
|
self._validate_lookup("%s/%s" % (vg.Name, lv_name), lv.object_path)
|
||||||
|
|
||||||
|
def test_prop_get(self):
|
||||||
|
lv_name = lv_n()
|
||||||
|
vg = self._vg_create().Vg
|
||||||
|
lv = self._test_lv_create(
|
||||||
|
vg.LvCreate,
|
||||||
|
(dbus.String(lv_name), dbus.UInt64(mib(4)),
|
||||||
|
dbus.Array([], signature='(ott)'), dbus.Int32(g_tmo),
|
||||||
|
EOD), vg, LV_BASE_INT)
|
||||||
|
ri = RemoteInterface(lv.dbus_object, interface=LV_COMMON_INT, introspect=False)
|
||||||
|
|
||||||
|
ri.update()
|
||||||
|
for prop_name in ri.get_property_names():
|
||||||
|
self.assertEqual(ri.get_property_value(prop_name), getattr(ri, prop_name))
|
||||||
|
|
||||||
def test_lv_create_job(self):
|
def test_lv_create_job(self):
|
||||||
lv_name = lv_n()
|
lv_name = lv_n()
|
||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
|
@ -183,6 +183,7 @@ class RemoteInterface(object):
|
|||||||
verify_type(
|
verify_type(
|
||||||
vl, self.introspect[self.interface]
|
vl, self.introspect[self.interface]
|
||||||
['properties'][kl]['p_type'])
|
['properties'][kl]['p_type'])
|
||||||
|
self.p_name[kl] = True
|
||||||
setattr(self, kl, vl)
|
setattr(self, kl, vl)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -196,6 +197,7 @@ class RemoteInterface(object):
|
|||||||
self.interface = interface
|
self.interface = interface
|
||||||
self.introspect = introspect
|
self.introspect = introspect
|
||||||
self.tmo = 0
|
self.tmo = 0
|
||||||
|
self.p_name = {}
|
||||||
|
|
||||||
if timelimit >= 0:
|
if timelimit >= 0:
|
||||||
self.tmo = float(timelimit)
|
self.tmo = float(timelimit)
|
||||||
@ -213,7 +215,7 @@ class RemoteInterface(object):
|
|||||||
|
|
||||||
def _wrapper(self, _method_name, *args, **kwargs):
|
def _wrapper(self, _method_name, *args, **kwargs):
|
||||||
|
|
||||||
# Lets see how long a method takes to execute, in call cases we should
|
# Let's see how long a method takes to execute, in call cases we should
|
||||||
# return something when the time limit has been reached.
|
# return something when the time limit has been reached.
|
||||||
start = time.time()
|
start = time.time()
|
||||||
result = getattr(self.dbus_interface, _method_name)(*args, **kwargs)
|
result = getattr(self.dbus_interface, _method_name)(*args, **kwargs)
|
||||||
@ -241,6 +243,14 @@ class RemoteInterface(object):
|
|||||||
def update(self):
|
def update(self):
|
||||||
self._set_props()
|
self._set_props()
|
||||||
|
|
||||||
|
def get_property_names(self):
|
||||||
|
return self.p_name.keys()
|
||||||
|
|
||||||
|
def get_property_value(self, name):
|
||||||
|
prop_interface = dbus.Interface(
|
||||||
|
self.dbus_object, 'org.freedesktop.DBus.Properties')
|
||||||
|
return prop_interface.Get(self.interface, name)
|
||||||
|
|
||||||
|
|
||||||
class ClientProxy(object):
|
class ClientProxy(object):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user