X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_component.py;h=e347d98160005521c2af1980ff8ef6845fee9cb4;hb=16c02b481c4194df6c334031515a7716f216eb26;hp=77d346b62c7cdea1024b84623029470d9c4cd6fb;hpb=c4239792c6758f579fb9482ddccf336f1bbf26c4;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_component.py b/tests/bindings/python/bt2/test_component.py index 77d346b6..e347d981 100644 --- a/tests/bindings/python/bt2/test_component.py +++ b/tests/bindings/python/bt2/test_component.py @@ -1,49 +1,62 @@ -from bt2 import value +# +# 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. +# + import unittest import copy import bt2 -@unittest.skip("this is broken") class UserComponentTestCase(unittest.TestCase): @staticmethod - def _create_comp(comp_cls, name=None): + def _create_comp(comp_cls, name=None, log_level=bt2.LoggingLevel.NONE): graph = bt2.Graph() if name is None: name = 'comp' - return graph.add_component(comp_cls, name) + return graph.add_component(comp_cls, name, logging_level=log_level) def test_name(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, params): self.assertEqual(comp_self.name, 'yaes') - def _consume(self): + def _user_consume(self): pass comp = self._create_comp(MySink, 'yaes') - def test_graph(self): + def test_logging_level(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, params): - nonlocal graph - self.assertEqual(comp_self.graph, graph) + self.assertEqual(comp_self.logging_level, bt2.LoggingLevel.INFO) - def _consume(self): + def _user_consume(self): pass - graph = bt2.Graph() - comp = graph.add_component(MySink, 'lel') - del graph + comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO) def test_class(self): class MySink(bt2._UserSinkComponent): def __init__(comp_self, params): - self.assertEqual(comp_self.component_class, MySink) + self.assertEqual(comp_self.cls, MySink) - def _consume(self): + def _user_consume(self): pass self._create_comp(MySink) @@ -54,7 +67,7 @@ class UserComponentTestCase(unittest.TestCase): self.assertIsInstance(comp_self.addr, int) self.assertNotEqual(comp_self.addr, 0) - def _consume(self): + def _user_consume(self): pass self._create_comp(MySink) @@ -63,59 +76,58 @@ class UserComponentTestCase(unittest.TestCase): finalized = False class MySink(bt2._UserSinkComponent): - def _consume(self): + def _user_consume(self): pass - def _finalize(comp_self): + def _user_finalize(comp_self): nonlocal finalized finalized = True graph = bt2.Graph() comp = graph.add_component(MySink, 'lel') + del graph del comp self.assertTrue(finalized) -@unittest.skip("this is broken") class GenericComponentTestCase(unittest.TestCase): @staticmethod - def _create_comp(comp_cls, name=None): + def _create_comp(comp_cls, name=None, log_level=bt2.LoggingLevel.NONE): graph = bt2.Graph() if name is None: name = 'comp' - return graph.add_component(comp_cls, name) + return graph.add_component(comp_cls, name, logging_level=log_level) def test_name(self): class MySink(bt2._UserSinkComponent): - def _consume(self): + def _user_consume(self): pass comp = self._create_comp(MySink, 'yaes') self.assertEqual(comp.name, 'yaes') - def test_graph(self): + def test_logging_level(self): class MySink(bt2._UserSinkComponent): - def _consume(self): + def _user_consume(self): pass - graph = bt2.Graph() - comp = graph.add_component(MySink, 'lel') - self.assertEqual(comp.graph, graph) + comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.WARNING) + self.assertEqual(comp.logging_level, bt2.LoggingLevel.WARNING) def test_class(self): class MySink(bt2._UserSinkComponent): - def _consume(self): + def _user_consume(self): pass comp = self._create_comp(MySink) - self.assertEqual(comp.component_class, MySink) + self.assertEqual(comp.cls, MySink) def test_addr(self): class MySink(bt2._UserSinkComponent): - def _consume(self): + def _user_consume(self): pass comp = self._create_comp(MySink)