def test_interpret_dict_as_qos_profile_valid(self): qos_dict = {'history': 'keep_last', 'depth': 10} qos_profile = interpret_dict_as_qos_profile(qos_dict) assert qos_profile.history == QoSHistoryPolicy.KEEP_LAST expected_seconds = 1 expected_nanoseconds = int((expected_seconds * 1e9)) qos_dict = {'history': 'keep_all', 'deadline': {'sec': expected_seconds, 'nsec': 0}} qos_profile = interpret_dict_as_qos_profile(qos_dict) assert qos_profile.deadline.nanoseconds == expected_nanoseconds expected_convention = False qos_dict = {'history': 'keep_all', 'avoid_ros_namespace_conventions': expected_convention} qos_profile = interpret_dict_as_qos_profile(qos_dict) assert qos_profile.avoid_ros_namespace_conventions == expected_convention
def test_interpret_dict_as_qos_profile_negative(self): qos_dict = {'history': 'keep_all', 'depth': -1} with self.assertRaises(ValueError): interpret_dict_as_qos_profile(qos_dict) qos_dict = {'history': 'keep_all', 'deadline': {'sec': -1, 'nsec': -1}} with self.assertRaises(ValueError): interpret_dict_as_qos_profile(qos_dict) qos_dict = {'history': 'keep_all', 'lifespan': {'sec': -1, 'nsec': -1}} with self.assertRaises(ValueError): interpret_dict_as_qos_profile(qos_dict) qos_dict = {'history': 'keep_all', 'liveliness_lease_duration': {'sec': -1, 'nsec': -1}} with self.assertRaises(ValueError): interpret_dict_as_qos_profile(qos_dict)
def test_interpret_dict_as_qos_profile_invalid(self): qos_dict = {'foo': 'bar'} with self.assertRaises(ValueError): interpret_dict_as_qos_profile(qos_dict)