def test_dbus_unwrap_dict(self): dbus_value = dbus.Dictionary({ dbus.String('a', variant_level=1): dbus.Double(3.2, variant_level=1), dbus.String('b', variant_level=1): dbus.Double(3.7, variant_level=1)}, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, dict) self.assertEqual({'a':3.2, 'b':3.7}, value)
def test_dbus_unwrap_array(self): dbus_value = dbus.Array( [dbus.Int32(3, variant_level=1), dbus.Int32(7, variant_level=1)], variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, list) self.assertEqual([3, 7], value)
def test_dbus_unwrap_dict(self): dbus_value = dbus.Dictionary( { dbus.String('a', variant_level=1): dbus.Double(3.2, variant_level=1), dbus.String('b', variant_level=1): dbus.Double(3.7, variant_level=1) }, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, dict) self.assertEqual({'a': 3.2, 'b': 3.7}, value)
def test_dbus_unwrap_empty_array(self): dbus_value = dbus.Array([], variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsNone(value)
def test_dbus_unwrap_array(self): dbus_value = dbus.Array([dbus.Int32(3, variant_level=1), dbus.Int32(7, variant_level=1)], variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, list) self.assertEqual([3, 7], value)
def test_dbus_unwrap_string(self): dbus_value = dbus.String('abcd', variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, unicode) self.assertEqual(str(dbus_value), value)
def test_dbus_unwrap_int64_large(self): dbus_value = dbus.Int64(33232133232323L, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, int) self.assertEqual(int(dbus_value), value)
def test_dbus_unwrap_int32(self): dbus_value = dbus.Int32(123, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, int) self.assertEqual(int(dbus_value), value)
def test_dbus_unwrap_byte(self): dbus_value = dbus.Byte(245, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, int) self.assertEqual(int(dbus_value), value)
def test_dbus_unwrap_double(self): dbus_value = dbus.Double(1.23, variant_level=1) value = dbus_mqtt.unwrap_dbus_value(dbus_value) self.assertIsInstance(value, float) self.assertEqual(float(dbus_value), value)