1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2019 EfficiOS Inc.
8 from bt2
import connection
as bt2_connection
9 from bt2
import port
as bt2_port
12 class ConnectionTestCase(unittest
.TestCase
):
13 def test_create(self
):
15 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
17 def __init__(self
, config
, params
, obj
):
18 self
._add
_output
_port
('out')
20 class MySink(bt2
._UserSinkComponent
):
21 def __init__(self
, config
, params
, obj
):
22 self
._add
_input
_port
('in')
24 def _user_consume(self
):
28 src
= graph
.add_component(MySource
, 'src')
29 sink
= graph
.add_component(MySink
, 'sink')
30 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
31 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
33 def test_downstream_port(self
):
35 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
37 def __init__(self
, config
, params
, obj
):
38 self
._add
_output
_port
('out')
40 class MySink(bt2
._UserSinkComponent
):
41 def __init__(self
, config
, params
, obj
):
42 self
._add
_input
_port
('in')
44 def _user_consume(self
):
48 src
= graph
.add_component(MySource
, 'src')
49 sink
= graph
.add_component(MySink
, 'sink')
50 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
51 self
.assertEqual(conn
.downstream_port
.addr
, sink
.input_ports
['in'].addr
)
52 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
53 self
.assertIs(type(conn
.downstream_port
), bt2_port
._InputPortConst
)
55 def test_upstream_port(self
):
57 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
59 def __init__(self
, config
, params
, obj
):
60 self
._add
_output
_port
('out')
62 class MySink(bt2
._UserSinkComponent
):
63 def __init__(self
, config
, params
, obj
):
64 self
._add
_input
_port
('in')
66 def _user_consume(self
):
70 src
= graph
.add_component(MySource
, 'src')
71 sink
= graph
.add_component(MySink
, 'sink')
72 conn
= graph
.connect_ports(src
.output_ports
['out'], sink
.input_ports
['in'])
73 self
.assertEqual(conn
.upstream_port
.addr
, src
.output_ports
['out'].addr
)
74 self
.assertIs(type(conn
.upstream_port
), bt2_port
._OutputPortConst
)
77 if __name__
== '__main__':
This page took 0.031315 seconds and 4 git commands to generate.