test_util.py
Go to the documentation of this file.
1 from mqtt_bridge.bridge import RosToMqttBridge
2 from mqtt_bridge.util import extract_values, populate_instance, lookup_object
3 from sensor_msgs.msg import Temperature
4 from std_msgs.msg import Header, String, Bool
5 
6 
8  obj = lookup_object('mqtt_bridge.bridge:RosToMqttBridge')
9  assert obj == RosToMqttBridge
10 
11 
13  msg = Temperature(
14  header=Header(),
15  temperature=25.2,
16  variance=0.0,
17  )
18  expected = {'header': {'stamp': {'secs': 0, 'nsecs': 0}, 'frame_id': '', 'seq': 0}, 'temperature': 25.2, 'variance': 0.0}
19  actual = extract_values(msg)
20  assert expected == actual
21 
22 
24  msg = String("hello")
25  expected = {'data': 'hello'}
26  actual = extract_values(msg)
27  assert expected == actual
28 
29 
31  msg_dict = {'header': {'stamp': {'secs': 0, 'nsecs': 0}, 'frame_id': '', 'seq': 0}, 'temperature': 25.2, 'variance': 0.0}
32  msg = Temperature()
33  populate_instance(msg_dict, msg)
34  assert msg.temperature == 25.2
35  assert msg.variance == 0.0
36 
37 
39  msg_dict = {'data': True}
40  msg = Bool()
41  populate_instance(msg_dict, msg)
42  assert msg.data == True
def test_extract_values_priimtive()
Definition: test_util.py:23
def test_populate_instance_primitive()
Definition: test_util.py:38
def test_extract_values()
Definition: test_util.py:12
def test_populate_instance()
Definition: test_util.py:30
def lookup_object
Definition: util.py:7
def test_lookup_object()
Definition: test_util.py:7


mqtt_bridge
Author(s): Junya Hayashi
autogenerated on Mon Feb 15 2021 03:57:51