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
, message_iterator_class
=MyIter
):
30 def __init__(self
, params
, obj
):
31 self
._add
_output
_port
('out')
33 class MySink(bt2
._UserSinkComponent
):
34 def __init__(self
, params
, obj
):
35 self
._add
_input
_port
('in')
37 def _user_consume(self
):
41 src
= graph
.add_component(MySource
, 'src')
42 sink
= graph
.add_component(MySink
, 'sink')
43 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
45 def test_downstream_port(self
):
46 class MyIter(bt2
._UserMessageIterator
):
50 class MySource(bt2
._UserSourceComponent
, message_iterator_class
=MyIter
):
51 def __init__(self
, params
, obj
):
52 self
._add
_output
_port
('out')
54 class MySink(bt2
._UserSinkComponent
):
55 def __init__(self
, params
, obj
):
56 self
._add
_input
_port
('in')
58 def _user_consume(self
):
62 src
= graph
.add_component(MySource
, 'src')
63 sink
= graph
.add_component(MySink
, 'sink')
64 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
65 self
.assertEqual(conn
.downstream_port
.addr
, sink
.input_ports
['in'].addr
)
67 def test_upstream_port(self
):
68 class MyIter(bt2
._UserMessageIterator
):
72 class MySource(bt2
._UserSourceComponent
, message_iterator_class
=MyIter
):
73 def __init__(self
, params
, obj
):
74 self
._add
_output
_port
('out')
76 class MySink(bt2
._UserSinkComponent
):
77 def __init__(self
, params
, obj
):
78 self
._add
_input
_port
('in')
80 def _user_consume(self
):
84 src
= graph
.add_component(MySource
, 'src')
85 sink
= graph
.add_component(MySink
, 'sink')
86 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
87 self
.assertEqual(conn
.upstream_port
.addr
, src
.output_ports
['out'].addr
)
This page took 0.032104 seconds and 4 git commands to generate.