4664ffce6ee19da413e22f48df5d8c111d59cd75
1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2019 EfficiOS Inc.
9 from bt2
import port
as bt2_port
10 from bt2
import connection
as bt2_connection
13 class ConnectionTestCase(unittest
.TestCase
):
14 def test_create(self
):
16 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
18 def __init__(self
, config
, params
, obj
):
19 self
._add
_output
_port
("out")
21 class MySink(bt2
._UserSinkComponent
):
22 def __init__(self
, config
, params
, obj
):
23 self
._add
_input
_port
("in")
25 def _user_consume(self
):
29 src
= graph
.add_component(MySource
, "src")
30 sink
= graph
.add_component(MySink
, "sink")
31 conn
= graph
.connect_ports(src
.output_ports
["out"], sink
.input_ports
["in"])
32 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
34 def test_downstream_port(self
):
36 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
38 def __init__(self
, config
, params
, obj
):
39 self
._add
_output
_port
("out")
41 class MySink(bt2
._UserSinkComponent
):
42 def __init__(self
, config
, params
, obj
):
43 self
._add
_input
_port
("in")
45 def _user_consume(self
):
49 src
= graph
.add_component(MySource
, "src")
50 sink
= graph
.add_component(MySink
, "sink")
51 conn
= graph
.connect_ports(src
.output_ports
["out"], sink
.input_ports
["in"])
52 self
.assertEqual(conn
.downstream_port
.addr
, sink
.input_ports
["in"].addr
)
53 self
.assertIs(type(conn
), bt2_connection
._ConnectionConst
)
54 self
.assertIs(type(conn
.downstream_port
), bt2_port
._InputPortConst
)
56 def test_upstream_port(self
):
58 bt2
._UserSourceComponent
, message_iterator_class
=bt2
._UserMessageIterator
60 def __init__(self
, config
, params
, obj
):
61 self
._add
_output
_port
("out")
63 class MySink(bt2
._UserSinkComponent
):
64 def __init__(self
, config
, params
, obj
):
65 self
._add
_input
_port
("in")
67 def _user_consume(self
):
71 src
= graph
.add_component(MySource
, "src")
72 sink
= graph
.add_component(MySink
, "sink")
73 conn
= graph
.connect_ports(src
.output_ports
["out"], sink
.input_ports
["in"])
74 self
.assertEqual(conn
.upstream_port
.addr
, src
.output_ports
["out"].addr
)
75 self
.assertIs(type(conn
.upstream_port
), bt2_port
._OutputPortConst
)
78 if __name__
== "__main__":
This page took 0.032439 seconds and 5 git commands to generate.