+# SPDX-License-Identifier: GPL-2.0-only
#
# 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 bt2
self.assertEqual(comp.logging_level, bt2.LoggingLevel.DEBUG)
def test_connect_ports(self):
- class MyIter(bt2._UserMessageIterator):
- def __next__(self):
- raise bt2.Stop
-
- class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+ class MySource(
+ bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+ ):
def __init__(self, config, params, obj):
self._add_output_port('out')
self.assertEqual(sink.input_ports['in'].connection.addr, conn.addr)
def test_connect_ports_invalid_direction(self):
- class MyIter(bt2._UserMessageIterator):
- def __next__(self):
- raise bt2.Stop
-
- class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+ class MySource(
+ bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+ ):
def __init__(self, config, params, obj):
self._add_output_port('out')
next(self._msg_iter)
def _user_graph_is_configured(self):
- self._msg_iter = self._create_input_port_message_iterator(
- self._input_ports['in']
- )
+ self._msg_iter = self._create_message_iterator(self._input_ports['in'])
# add two interrupters, set one of them
interrupter1 = bt2.Interrupter()
return next(self._msg_iter)
def _user_graph_is_configured(self):
- self._msg_iter = self._create_input_port_message_iterator(
- self._input_ports['in']
- )
+ self._msg_iter = self._create_message_iterator(self._input_ports['in'])
graph = self._graph
up = self._graph.add_component(MySource, 'down')
comp_self._at += 1
def _user_graph_is_configured(self):
- self._msg_iter = self._create_input_port_message_iterator(
- self._input_port
- )
+ self._msg_iter = self._create_message_iterator(self._input_port)
src = self._graph.add_component(MySource, 'src')
sink = self._graph.add_component(MySink, 'sink')
comp_self._at += 1
def _user_graph_is_configured(self):
- self._msg_iter = self._create_input_port_message_iterator(
- self._input_port
- )
+ self._msg_iter = self._create_message_iterator(self._input_port)
src = self._graph.add_component(MySource, 'src')
sink = self._graph.add_component(MySink, 'sink')
comp_self._at += 1
def _user_graph_is_configured(self):
- self._msg_iter = self._create_input_port_message_iterator(
- self._input_port
- )
+ self._msg_iter = self._create_message_iterator(self._input_port)
src = self._graph.add_component(MySource, 'src')
sink = self._graph.add_component(MySink, 'sink')
self._graph.run()
def test_listeners(self):
- class MyIter(bt2._UserMessageIterator):
- def __next__(self):
- raise bt2.Stop
-
- class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+ class MySource(
+ bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+ ):
def __init__(self, config, params, obj):
self._add_output_port('out')
self._add_output_port('zero')
self.assertEqual(calls[3][2].name, 'taste')
def test_invalid_listeners(self):
- class MyIter(bt2._UserMessageIterator):
- def __next__(self):
- raise bt2.Stop
-
- class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+ class MySource(
+ bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+ ):
def __init__(self, config, params, obj):
self._add_output_port('out')
self._add_output_port('zero')