From 8ef46e792223fb34cfdce43fbaee6257d4c44583 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 14 Jun 2019 21:48:50 -0400 Subject: [PATCH] test_graph.py: add bt2.Graph.add_component() logging level parameter tests GraphTestCase.test_add_component_logging_level() is pretty much the same test as GenericComponentTestCase.test_logging_level(), but the former's purpose is to test the bt2.Graph.add_component() part of this, while the latter tests the component's public `logging_level` property. Signed-off-by: Philippe Proulx Change-Id: I9c82e8a7ab6a733810eabfee5ccef66cd619a610 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1456 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- tests/bindings/python/bt2/test_graph.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index bd1fec1a..85b6bbde 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -79,6 +79,31 @@ class GraphTestCase(unittest.TestCase): with self.assertRaises(TypeError): self._graph.add_component(int, 'salut') + def test_add_component_invalid_logging_level_type(self): + class MySink(bt2._UserSinkComponent): + def _consume(self): + pass + + with self.assertRaises(TypeError): + self._graph.add_component(MySink, 'salut', logging_level='yo') + + def test_add_component_invalid_logging_level_value(self): + class MySink(bt2._UserSinkComponent): + def _consume(self): + pass + + with self.assertRaises(ValueError): + self._graph.add_component(MySink, 'salut', logging_level=12345) + + def test_add_component_logging_level(self): + class MySink(bt2._UserSinkComponent): + def _consume(self): + pass + + comp = self._graph.add_component(MySink, 'salut', + logging_level=bt2.LoggingLevel.DEBUG) + self.assertEqual(comp.logging_level, bt2.LoggingLevel.DEBUG) + def test_connect_ports(self): class MyIter(bt2._UserMessageIterator): def __next__(self): -- 2.34.1