X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_graph.py;h=8c2a0621f2f0b6bcbed107dface114a2ab5a561b;hb=3e03e5e334d6a995f4fc63f52b6d6745688f640f;hp=744f6429274662c23ae5370cbb075d9ae93b5b04;hpb=9415de1c45ec07f42cad51e398181e91a839a5e6;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index 744f6429..8c2a0621 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -159,6 +159,48 @@ class GraphTestCase(unittest.TestCase): 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):