2 # Copyright (C) 2019 EfficiOS Inc.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; only version 2
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 class ConnectionTestCase(unittest
.TestCase
):
24 def test_create(self
):
25 class MyIter(bt2
._UserMessageIterator
):
29 class MySource(bt2
._UserSourceComponent
,
30 message_iterator_class
=MyIter
):
31 def __init__(self
, params
):
32 self
._add
_output
_port
('out')
34 class MySink(bt2
._UserSinkComponent
):
35 def __init__(self
, params
):
36 self
._add
_input
_port
('in')
42 src
= graph
.add_component(MySource
, 'src')
43 sink
= graph
.add_component(MySink
, 'sink')
44 conn
= graph
.connect_ports(src
.output_ports
['out'],
45 sink
.input_ports
['in'])
46 self
.assertIsInstance(conn
, bt2
._Connection
)
48 def test_downstream_port(self
):
49 class MyIter(bt2
._UserMessageIterator
):
53 class MySource(bt2
._UserSourceComponent
,
54 message_iterator_class
=MyIter
):
55 def __init__(self
, params
):
56 self
._add
_output
_port
('out')
58 class MySink(bt2
._UserSinkComponent
):
59 def __init__(self
, params
):
60 self
._add
_input
_port
('in')
66 src
= graph
.add_component(MySource
, 'src')
67 sink
= graph
.add_component(MySink
, 'sink')
68 conn
= graph
.connect_ports(src
.output_ports
['out'],
69 sink
.input_ports
['in'])
70 self
.assertEqual(conn
.downstream_port
.addr
, sink
.input_ports
['in'].addr
)
72 def test_upstream_port(self
):
73 class MyIter(bt2
._UserMessageIterator
):
77 class MySource(bt2
._UserSourceComponent
,
78 message_iterator_class
=MyIter
):
79 def __init__(self
, params
):
80 self
._add
_output
_port
('out')
82 class MySink(bt2
._UserSinkComponent
):
83 def __init__(self
, params
):
84 self
._add
_input
_port
('in')
90 src
= graph
.add_component(MySource
, 'src')
91 sink
= graph
.add_component(MySink
, 'sink')
92 conn
= graph
.connect_ports(src
.output_ports
['out'],
93 sink
.input_ports
['in'])
94 self
.assertEqual(conn
.upstream_port
.addr
, src
.output_ports
['out'].addr
)
This page took 0.032376 seconds and 4 git commands to generate.