Пример #1
0
	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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
	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)
Пример #5
0
	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)
Пример #6
0
	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)
Пример #7
0
	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)
Пример #8
0
	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)
Пример #9
0
	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)
Пример #10
0
	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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
 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)
Пример #14
0
 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)
Пример #15
0
 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)
Пример #16
0
 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)