test_graph.py: add bt2.Graph.add_component() logging level parameter tests
[babeltrace.git] / 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.024729 seconds and 4 git commands to generate.