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.
21 from bt2
import connection
as bt2_connection
22 from bt2
import port
as bt2_port
25 class ConnectionTestCase(unittest
.TestCase
):
26 def test_create(self
):
28 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
30 def __init__(self
, config
, params
, obj
):
31 self
._add
_output
_port
('out')
33 class MySink(bt2
._UserSinkComponent
):
34 def __init__(self
, config
, 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'])
44 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
46 def test_downstream_port(self
):
48 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
50 def __init__(self
, config
, params
, obj
):
51 self
._add
_output
_port
('out')
53 class MySink(bt2
._UserSinkComponent
):
54 def __init__(self
, config
, params
, obj
):
55 self
._add
_input
_port
('in')
57 def _user_consume(self
):
61 src
= graph
.add_component(MySource
, 'src')
62 sink
= graph
.add_component(MySink
, 'sink')
63 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
64 self
.assertEqual(conn
.downstream_port
.addr
, sink
.input_ports
['in'].addr
)
65 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
66 self
.assertIs(type(conn
.downstream_port
), bt2_port
._InputPortConst
)
68 def test_upstream_port(self
):
70 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
72 def __init__(self
, config
, params
, obj
):
73 self
._add
_output
_port
('out')
75 class MySink(bt2
._UserSinkComponent
):
76 def __init__(self
, config
, params
, obj
):
77 self
._add
_input
_port
('in')
79 def _user_consume(self
):
83 src
= graph
.add_component(MySource
, 'src')
84 sink
= graph
.add_component(MySink
, 'sink')
85 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
86 self
.assertEqual(conn
.upstream_port
.addr
, src
.output_ports
['out'].addr
)
87 self
.assertIs(type(conn
.upstream_port
), bt2_port
._OutputPortConst
)
90 if __name__
== '__main__':
This page took 0.031503 seconds and 4 git commands to generate.