test_graph.py: add bt2.Graph.add_component() logging level parameter tests
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 15 Jun 2019 01:48:50 +0000 (21:48 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
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 <eeppeliteloop@gmail.com>
Change-Id: I9c82e8a7ab6a733810eabfee5ccef66cd619a610
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1456
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
tests/bindings/python/bt2/test_graph.py

index bd1fec1a677ca2e12d217e2f3d78f5489f9971f7..85b6bbde32618de167b3828278c27c37da0471a6 100644 (file)
@@ -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):
This page took 0.026349 seconds and 4 git commands to generate.