class _MyIter(bt2._UserMessageIterator):
- def __init__(self, self_output_port):
+ def __init__(self, config, self_output_port):
self._build_meta()
self._at = 0
comp_params = None
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
nonlocal comp_params
comp_params = params
comp_obj = None
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
nonlocal comp_obj
comp_obj = obj
comp_obj = None
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
nonlocal comp_obj
comp_obj = obj
with self.assertRaises(ValueError):
self._graph.add_component(MySink, 'salut', logging_level=12345)
+ def test_add_component_invalid_params_type(self):
+ class MySink(bt2._UserSinkComponent):
+ def _user_consume(self):
+ pass
+
+ with self.assertRaises(TypeError):
+ self._graph.add_component(MySink, 'salut', params=12)
+
+ def test_add_component_params_dict(self):
+ params_obj = None
+
+ class MySink(bt2._UserSinkComponent):
+ def __init__(self, config, params, obj):
+ nonlocal params_obj
+ params_obj = params
+
+ def _user_consume(self):
+ pass
+
+ params = {'plage': 12312}
+ self._graph.add_component(MySink, 'salut', params=params)
+
+ # Check equality and not identity because `add_component()` method
+ # converts the Python `dict` to a `bt2.MapValue`.
+ self.assertEqual(params, params_obj)
+
+ def test_add_component_params_mapvalue(self):
+ params_obj = None
+
+ class MySink(bt2._UserSinkComponent):
+ def __init__(self, config, params, obj):
+ nonlocal params_obj
+ params_obj = params
+
+ def _user_consume(self):
+ pass
+
+ params = bt2.MapValue({'beachclub': '121'})
+ self._graph.add_component(MySink, 'salut', params=params)
+
+ self.assertEqual(params, params_obj)
+
def test_add_component_logging_level(self):
class MySink(bt2._UserSinkComponent):
def _user_consume(self):
raise bt2.Stop
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
raise bt2.Stop
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
raise TypeError
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
return self._create_stream_beginning_message(self._stream)
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
return msg
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._input_port = self._add_input_port('in')
self._at = 0
pass
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._input_port = self._add_input_port('in')
def _user_consume(comp_self):
pass
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._input_port = self._add_input_port('in')
def _user_consume(comp_self):
return msg
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._input_port = self._add_input_port('in')
self._at = 0
return msg
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._input_port = self._add_input_port('in')
self._at = 0
raise bt2.Stop
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
self._add_output_port('zero')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
raise bt2.Stop
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
self._add_output_port('zero')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
def test_raise_in_component_init(self):
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
raise ValueError('oops!')
def _user_consume(self):
def test_raise_in_port_added_listener(self):
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):
raise bt2.Stop
class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_output_port('out')
class MySink(bt2._UserSinkComponent):
- def __init__(self, params, obj):
+ def __init__(self, config, params, obj):
self._add_input_port('in')
def _user_consume(self):