bt2: check for _graph_is_configured method in user sink classes
[babeltrace.git] / tests / bindings / python / bt2 / test_component_class.py
index 228ef9c73345bfe4bbd07180a76698726e687426..cece1a56b39aed8e1fa7a218f12dfa65720674b0 100644 (file)
@@ -1,3 +1,21 @@
+#
+# Copyright (C) 2019 EfficiOS Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; only version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+
 from bt2 import value
 import unittest
 import bt2
@@ -35,6 +53,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self._test_no_init(MySink)
 
     def test_incomplete_source_no_msg_iter_cls(self):
@@ -91,11 +112,17 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
     def test_default_name(self):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertEqual(MySink.name, 'MySink')
 
     def test_custom_name(self):
@@ -103,6 +130,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertEqual(MySink.name, 'salut')
 
     def test_invalid_custom_name(self):
@@ -111,6 +141,9 @@ class UserComponentClassTestCase(unittest.TestCase):
                 def _consume(self):
                     pass
 
+                def _graph_is_configured(self):
+                    pass
+
     def test_description(self):
         class MySink(bt2._UserSinkComponent):
             """
@@ -126,6 +159,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertEqual(MySink.description, 'The description.')
 
     def test_empty_description(self):
@@ -136,6 +172,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertIsNone(MySink.description)
 
     def test_help(self):
@@ -151,6 +190,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertEqual(MySink.help, 'The help\ntext is\nhere.')
 
     def test_addr(self):
@@ -158,6 +200,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertIsInstance(MySink.addr, int)
         self.assertNotEqual(MySink.addr, 0)
 
@@ -166,6 +211,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         with self.assertRaises(bt2.Error):
             bt2.QueryExecutor().query(MySink, 'obj', 23)
 
@@ -174,6 +222,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 raise ValueError
@@ -186,6 +237,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 return ...
@@ -198,6 +252,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
@@ -216,6 +273,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_log_level
@@ -223,15 +283,33 @@ class UserComponentClassTestCase(unittest.TestCase):
 
         query_log_level = None
         res = bt2.QueryExecutor().query(MySink, 'obj', None,
-                                        bt2.LoggingLevel.WARN)
-        self.assertEqual(query_log_level, bt2.LoggingLevel.WARN)
+                                        bt2.LoggingLevel.WARNING)
+        self.assertEqual(query_log_level, bt2.LoggingLevel.WARNING)
         del query_log_level
 
+    def test_query_returns_none(self):
+        class MySink(bt2._UserSinkComponent):
+            def _consume(self):
+                pass
+
+            def _graph_is_configured(self):
+                pass
+
+            @staticmethod
+            def _query(query_exec, obj, params, log_level):
+                return
+
+        res = bt2.QueryExecutor().query(MySink, 'obj', None)
+        self.assertIsNone(res)
+
     def test_query_simple(self):
         class MySink(bt2._UserSinkComponent):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
@@ -250,6 +328,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 nonlocal query_params
@@ -283,6 +364,9 @@ class UserComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
         self.assertEqual(MySink, MySink)
 
 
@@ -297,6 +381,9 @@ class GenericComponentClassTestCase(unittest.TestCase):
             def _consume(self):
                 pass
 
+            def _graph_is_configured(self):
+                pass
+
             @classmethod
             def _query(cls, query_exec, obj, params, log_level):
                 return [obj, params, 23]
This page took 0.027104 seconds and 4 git commands to generate.