7 @unittest.skip("this is broken")
8 class PortTestCase(unittest
.TestCase
):
10 def _create_comp(comp_cls
, name
=None):
16 return graph
.add_component(comp_cls
, name
)
18 def test_src_add_output_port(self
):
19 class MyIter(bt2
._UserMessageIterator
):
23 class MySource(bt2
._UserSourceComponent
,
24 message_iterator_class
=MyIter
):
25 def __init__(comp_self
, params
):
26 port
= comp_self
._add
_output
_port
('out')
27 self
.assertEqual(port
.name
, 'out')
29 comp
= self
._create
_comp
(MySource
)
30 self
.assertEqual(len(comp
.output_ports
), 1)
33 def test_flt_add_output_port(self
):
34 class MyIter(bt2
._UserMessageIterator
):
38 class MyFilter(bt2
._UserFilterComponent
,
39 message_iterator_class
=MyIter
):
40 def __init__(comp_self
, params
):
41 port
= comp_self
._add
_output
_port
('out')
42 self
.assertEqual(port
.name
, 'out')
44 comp
= self
._create
_comp
(MyFilter
)
45 self
.assertEqual(len(comp
.output_ports
), 1)
47 def test_flt_add_input_port(self
):
48 class MyIter(bt2
._UserMessageIterator
):
52 class MyFilter(bt2
._UserFilterComponent
,
53 message_iterator_class
=MyIter
):
54 def __init__(comp_self
, params
):
55 port
= comp_self
._add
_input
_port
('in')
56 self
.assertEqual(port
.name
, 'in')
58 comp
= self
._create
_comp
(MyFilter
)
59 self
.assertEqual(len(comp
.input_ports
), 1)
61 def test_sink_add_input_port(self
):
62 class MySink(bt2
._UserSinkComponent
):
63 def __init__(comp_self
, params
):
64 port
= comp_self
._add
_input
_port
('in')
65 self
.assertEqual(port
.name
, 'in')
70 comp
= self
._create
_comp
(MySink
)
71 self
.assertEqual(len(comp
.input_ports
), 1)
73 def test_user_src_output_ports_getitem(self
):
74 class MyIter(bt2
._UserMessageIterator
):
78 class MySource(bt2
._UserSourceComponent
,
79 message_iterator_class
=MyIter
):
80 def __init__(comp_self
, params
):
81 port1
= comp_self
._add
_output
_port
('clear')
82 port2
= comp_self
._add
_output
_port
('print')
83 port3
= comp_self
._add
_output
_port
('insert')
84 self
.assertEqual(port3
.addr
, comp_self
._output
_ports
['insert'].addr
)
85 self
.assertEqual(port2
.addr
, comp_self
._output
_ports
['print'].addr
)
86 self
.assertEqual(port1
.addr
, comp_self
._output
_ports
['clear'].addr
)
88 comp
= self
._create
_comp
(MySource
)
90 def test_user_flt_output_ports_getitem(self
):
91 class MyIter(bt2
._UserMessageIterator
):
95 class MyFilter(bt2
._UserFilterComponent
,
96 message_iterator_class
=MyIter
):
97 def __init__(comp_self
, params
):
98 port1
= comp_self
._add
_output
_port
('clear')
99 port2
= comp_self
._add
_output
_port
('print')
100 port3
= comp_self
._add
_output
_port
('insert')
101 self
.assertEqual(port3
.addr
, comp_self
._output
_ports
['insert'].addr
)
102 self
.assertEqual(port2
.addr
, comp_self
._output
_ports
['print'].addr
)
103 self
.assertEqual(port1
.addr
, comp_self
._output
_ports
['clear'].addr
)
105 comp
= self
._create
_comp
(MyFilter
)
107 def test_user_flt_input_ports_getitem(self
):
108 class MyIter(bt2
._UserMessageIterator
):
112 class MyFilter(bt2
._UserFilterComponent
,
113 message_iterator_class
=MyIter
):
114 def __init__(comp_self
, params
):
115 port1
= comp_self
._add
_input
_port
('clear')
116 port2
= comp_self
._add
_input
_port
('print')
117 port3
= comp_self
._add
_input
_port
('insert')
118 self
.assertEqual(port3
.addr
, comp_self
._input
_ports
['insert'].addr
)
119 self
.assertEqual(port2
.addr
, comp_self
._input
_ports
['print'].addr
)
120 self
.assertEqual(port1
.addr
, comp_self
._input
_ports
['clear'].addr
)
122 comp
= self
._create
_comp
(MyFilter
)
124 def test_user_sink_input_ports_getitem(self
):
125 class MySink(bt2
._UserSinkComponent
):
126 def __init__(comp_self
, params
):
127 port1
= comp_self
._add
_input
_port
('clear')
128 port2
= comp_self
._add
_input
_port
('print')
129 port3
= comp_self
._add
_input
_port
('insert')
130 self
.assertEqual(port3
.addr
, comp_self
._input
_ports
['insert'].addr
)
131 self
.assertEqual(port2
.addr
, comp_self
._input
_ports
['print'].addr
)
132 self
.assertEqual(port1
.addr
, comp_self
._input
_ports
['clear'].addr
)
137 comp
= self
._create
_comp
(MySink
)
139 def test_user_src_output_ports_getitem_invalid_key(self
):
140 class MyIter(bt2
._UserMessageIterator
):
144 class MySource(bt2
._UserSourceComponent
,
145 message_iterator_class
=MyIter
):
146 def __init__(comp_self
, params
):
147 comp_self
._add
_output
_port
('clear')
148 comp_self
._add
_output
_port
('print')
149 comp_self
._add
_output
_port
('insert')
151 with self
.assertRaises(KeyError):
152 comp_self
._output
_ports
['hello']
154 comp
= self
._create
_comp
(MySource
)
156 def test_user_flt_output_ports_getitem_invalid_key(self
):
157 class MyIter(bt2
._UserMessageIterator
):
161 class MyFilter(bt2
._UserFilterComponent
,
162 message_iterator_class
=MyIter
):
163 def __init__(comp_self
, params
):
164 comp_self
._add
_output
_port
('clear')
165 comp_self
._add
_output
_port
('print')
166 comp_self
._add
_output
_port
('insert')
168 with self
.assertRaises(KeyError):
169 comp_self
._output
_ports
['hello']
171 comp
= self
._create
_comp
(MyFilter
)
173 def test_user_flt_input_ports_getitem_invalid_key(self
):
174 class MyIter(bt2
._UserMessageIterator
):
178 class MyFilter(bt2
._UserFilterComponent
,
179 message_iterator_class
=MyIter
):
180 def __init__(comp_self
, params
):
181 comp_self
._add
_input
_port
('clear')
182 comp_self
._add
_input
_port
('print')
183 comp_self
._add
_input
_port
('insert')
185 with self
.assertRaises(KeyError):
186 comp_self
._input
_ports
['hello']
188 comp
= self
._create
_comp
(MyFilter
)
190 def test_user_sink_input_ports_getitem_invalid_key(self
):
191 class MySink(bt2
._UserSinkComponent
):
192 def __init__(comp_self
, params
):
193 comp_self
._add
_input
_port
('clear')
194 comp_self
._add
_input
_port
('print')
195 comp_self
._add
_input
_port
('insert')
197 with self
.assertRaises(KeyError):
198 comp_self
._input
_ports
['hello']
203 comp
= self
._create
_comp
(MySink
)
205 def test_user_src_output_ports_len(self
):
206 class MyIter(bt2
._UserMessageIterator
):
210 class MySource(bt2
._UserSourceComponent
,
211 message_iterator_class
=MyIter
):
212 def __init__(comp_self
, params
):
213 comp_self
._add
_output
_port
('clear')
214 comp_self
._add
_output
_port
('print')
215 comp_self
._add
_output
_port
('insert')
216 self
.assertEqual(len(comp_self
._output
_ports
), 3)
218 comp
= self
._create
_comp
(MySource
)
220 def test_user_flt_output_ports_len(self
):
221 class MyIter(bt2
._UserMessageIterator
):
225 class MyFilter(bt2
._UserFilterComponent
,
226 message_iterator_class
=MyIter
):
227 def __init__(comp_self
, params
):
228 comp_self
._add
_output
_port
('clear')
229 comp_self
._add
_output
_port
('print')
230 comp_self
._add
_output
_port
('insert')
231 self
.assertEqual(len(comp_self
._output
_ports
), 3)
233 comp
= self
._create
_comp
(MyFilter
)
235 def test_user_flt_input_ports_len(self
):
236 class MyIter(bt2
._UserMessageIterator
):
240 class MyFilter(bt2
._UserFilterComponent
,
241 message_iterator_class
=MyIter
):
242 def __init__(comp_self
, params
):
243 comp_self
._add
_input
_port
('clear')
244 comp_self
._add
_input
_port
('print')
245 comp_self
._add
_input
_port
('insert')
246 self
.assertEqual(len(comp_self
._input
_ports
), 3)
248 comp
= self
._create
_comp
(MyFilter
)
250 def test_user_sink_input_ports_len(self
):
251 class MySink(bt2
._UserSinkComponent
):
252 def __init__(comp_self
, params
):
253 comp_self
._add
_input
_port
('clear')
254 comp_self
._add
_input
_port
('print')
255 comp_self
._add
_input
_port
('insert')
256 self
.assertEqual(len(comp_self
._input
_ports
), 3)
261 comp
= self
._create
_comp
(MySink
)
263 def test_user_src_output_ports_iter(self
):
264 class MyIter(bt2
._UserMessageIterator
):
268 class MySource(bt2
._UserSourceComponent
,
269 message_iterator_class
=MyIter
):
270 def __init__(comp_self
, params
):
271 port1
= comp_self
._add
_output
_port
('clear')
272 port2
= comp_self
._add
_output
_port
('print')
273 port3
= comp_self
._add
_output
_port
('insert')
276 for port_name
, port
in comp_self
._output
_ports
.items():
277 ports
.append((port_name
, port
))
279 self
.assertEqual(ports
[0][0], 'clear')
280 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
281 self
.assertEqual(ports
[1][0], 'print')
282 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
283 self
.assertEqual(ports
[2][0], 'insert')
284 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
286 comp
= self
._create
_comp
(MySource
)
288 def test_user_flt_output_ports_iter(self
):
289 class MyIter(bt2
._UserMessageIterator
):
293 class MyFilter(bt2
._UserFilterComponent
,
294 message_iterator_class
=MyIter
):
295 def __init__(comp_self
, params
):
296 port1
= comp_self
._add
_output
_port
('clear')
297 port2
= comp_self
._add
_output
_port
('print')
298 port3
= comp_self
._add
_output
_port
('insert')
301 for port_name
, port
in comp_self
._output
_ports
.items():
302 ports
.append((port_name
, port
))
304 self
.assertEqual(ports
[0][0], 'clear')
305 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
306 self
.assertEqual(ports
[1][0], 'print')
307 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
308 self
.assertEqual(ports
[2][0], 'insert')
309 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
311 comp
= self
._create
_comp
(MyFilter
)
313 def test_user_flt_input_ports_iter(self
):
314 class MyIter(bt2
._UserMessageIterator
):
318 class MyFilter(bt2
._UserFilterComponent
,
319 message_iterator_class
=MyIter
):
320 def __init__(comp_self
, params
):
321 port1
= comp_self
._add
_input
_port
('clear')
322 port2
= comp_self
._add
_input
_port
('print')
323 port3
= comp_self
._add
_input
_port
('insert')
326 for port_name
, port
in comp_self
._input
_ports
.items():
327 ports
.append((port_name
, port
))
329 self
.assertEqual(ports
[0][0], 'clear')
330 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
331 self
.assertEqual(ports
[1][0], 'print')
332 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
333 self
.assertEqual(ports
[2][0], 'insert')
334 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
336 comp
= self
._create
_comp
(MyFilter
)
338 def test_user_sink_input_ports_iter(self
):
339 class MySink(bt2
._UserSinkComponent
):
340 def __init__(comp_self
, params
):
341 port1
= comp_self
._add
_input
_port
('clear')
342 port2
= comp_self
._add
_input
_port
('print')
343 port3
= comp_self
._add
_input
_port
('insert')
346 for port_name
, port
in comp_self
._input
_ports
.items():
347 ports
.append((port_name
, port
))
349 self
.assertEqual(ports
[0][0], 'clear')
350 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
351 self
.assertEqual(ports
[1][0], 'print')
352 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
353 self
.assertEqual(ports
[2][0], 'insert')
354 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
359 comp
= self
._create
_comp
(MySink
)
361 def test_gen_src_output_ports_getitem(self
):
362 class MyIter(bt2
._UserMessageIterator
):
370 class MySource(bt2
._UserSourceComponent
,
371 message_iterator_class
=MyIter
):
372 def __init__(comp_self
, params
):
373 nonlocal port1
, port2
, port3
374 port1
= comp_self
._add
_output
_port
('clear')
375 port2
= comp_self
._add
_output
_port
('print')
376 port3
= comp_self
._add
_output
_port
('insert')
378 comp
= self
._create
_comp
(MySource
)
379 self
.assertEqual(port3
.addr
, comp
.output_ports
['insert'].addr
)
380 self
.assertEqual(port2
.addr
, comp
.output_ports
['print'].addr
)
381 self
.assertEqual(port1
.addr
, comp
.output_ports
['clear'].addr
)
386 def test_gen_flt_output_ports_getitem(self
):
387 class MyIter(bt2
._UserMessageIterator
):
395 class MyFilter(bt2
._UserFilterComponent
,
396 message_iterator_class
=MyIter
):
397 def __init__(comp_self
, params
):
398 nonlocal port1
, port2
, port3
399 port1
= comp_self
._add
_output
_port
('clear')
400 port2
= comp_self
._add
_output
_port
('print')
401 port3
= comp_self
._add
_output
_port
('insert')
403 comp
= self
._create
_comp
(MyFilter
)
404 self
.assertEqual(port3
.addr
, comp
.output_ports
['insert'].addr
)
405 self
.assertEqual(port2
.addr
, comp
.output_ports
['print'].addr
)
406 self
.assertEqual(port1
.addr
, comp
.output_ports
['clear'].addr
)
411 def test_gen_flt_input_ports_getitem(self
):
412 class MyIter(bt2
._UserMessageIterator
):
420 class MyFilter(bt2
._UserFilterComponent
,
421 message_iterator_class
=MyIter
):
422 def __init__(comp_self
, params
):
423 nonlocal port1
, port2
, port3
424 port1
= comp_self
._add
_input
_port
('clear')
425 port2
= comp_self
._add
_input
_port
('print')
426 port3
= comp_self
._add
_input
_port
('insert')
428 comp
= self
._create
_comp
(MyFilter
)
429 self
.assertEqual(port3
.addr
, comp
.input_ports
['insert'].addr
)
430 self
.assertEqual(port2
.addr
, comp
.input_ports
['print'].addr
)
431 self
.assertEqual(port1
.addr
, comp
.input_ports
['clear'].addr
)
436 def test_gen_sink_input_ports_getitem(self
):
441 class MySink(bt2
._UserSinkComponent
):
442 def __init__(comp_self
, params
):
443 nonlocal port1
, port2
, port3
444 port1
= comp_self
._add
_input
_port
('clear')
445 port2
= comp_self
._add
_input
_port
('print')
446 port3
= comp_self
._add
_input
_port
('insert')
451 comp
= self
._create
_comp
(MySink
)
452 self
.assertEqual(port3
.addr
, comp
.input_ports
['insert'].addr
)
453 self
.assertEqual(port2
.addr
, comp
.input_ports
['print'].addr
)
454 self
.assertEqual(port1
.addr
, comp
.input_ports
['clear'].addr
)
459 def test_gen_src_output_ports_getitem_invalid_key(self
):
460 class MyIter(bt2
._UserMessageIterator
):
464 class MySource(bt2
._UserSourceComponent
,
465 message_iterator_class
=MyIter
):
466 def __init__(comp_self
, params
):
467 comp_self
._add
_output
_port
('clear')
468 comp_self
._add
_output
_port
('print')
469 comp_self
._add
_output
_port
('insert')
471 comp
= self
._create
_comp
(MySource
)
473 with self
.assertRaises(KeyError):
474 comp
.output_ports
['hello']
476 def test_gen_flt_output_ports_getitem_invalid_key(self
):
477 class MyIter(bt2
._UserMessageIterator
):
481 class MyFilter(bt2
._UserFilterComponent
,
482 message_iterator_class
=MyIter
):
483 def __init__(comp_self
, params
):
484 comp_self
._add
_output
_port
('clear')
485 comp_self
._add
_output
_port
('print')
486 comp_self
._add
_output
_port
('insert')
488 comp
= self
._create
_comp
(MyFilter
)
490 with self
.assertRaises(KeyError):
491 comp
.output_ports
['hello']
493 def test_gen_flt_input_ports_getitem_invalid_key(self
):
494 class MyIter(bt2
._UserMessageIterator
):
498 class MyFilter(bt2
._UserFilterComponent
,
499 message_iterator_class
=MyIter
):
500 def __init__(comp_self
, params
):
501 comp_self
._add
_input
_port
('clear')
502 comp_self
._add
_input
_port
('print')
503 comp_self
._add
_input
_port
('insert')
505 comp
= self
._create
_comp
(MyFilter
)
507 with self
.assertRaises(KeyError):
508 comp
.input_ports
['hello']
510 def test_gen_sink_input_ports_getitem_invalid_key(self
):
511 class MySink(bt2
._UserSinkComponent
):
512 def __init__(comp_self
, params
):
513 comp_self
._add
_input
_port
('clear')
514 comp_self
._add
_input
_port
('print')
515 comp_self
._add
_input
_port
('insert')
517 with self
.assertRaises(KeyError):
518 comp_self
._input
_ports
['hello']
523 comp
= self
._create
_comp
(MySink
)
525 with self
.assertRaises(KeyError):
526 comp
.input_ports
['hello']
528 def test_gen_src_output_ports_len(self
):
529 class MyIter(bt2
._UserMessageIterator
):
533 class MySource(bt2
._UserSourceComponent
,
534 message_iterator_class
=MyIter
):
535 def __init__(comp_self
, params
):
536 comp_self
._add
_output
_port
('clear')
537 comp_self
._add
_output
_port
('print')
538 comp_self
._add
_output
_port
('insert')
540 comp
= self
._create
_comp
(MySource
)
541 self
.assertEqual(len(comp
.output_ports
), 3)
543 def test_gen_flt_output_ports_len(self
):
544 class MyIter(bt2
._UserMessageIterator
):
548 class MyFilter(bt2
._UserFilterComponent
,
549 message_iterator_class
=MyIter
):
550 def __init__(comp_self
, params
):
551 comp_self
._add
_output
_port
('clear')
552 comp_self
._add
_output
_port
('print')
553 comp_self
._add
_output
_port
('insert')
555 comp
= self
._create
_comp
(MyFilter
)
556 self
.assertEqual(len(comp
.output_ports
), 3)
558 def test_gen_flt_input_ports_len(self
):
559 class MyIter(bt2
._UserMessageIterator
):
563 class MyFilter(bt2
._UserFilterComponent
,
564 message_iterator_class
=MyIter
):
565 def __init__(comp_self
, params
):
566 comp_self
._add
_input
_port
('clear')
567 comp_self
._add
_input
_port
('print')
568 comp_self
._add
_input
_port
('insert')
570 comp
= self
._create
_comp
(MyFilter
)
571 self
.assertEqual(len(comp
.input_ports
), 3)
573 def test_gen_sink_input_ports_len(self
):
574 class MySink(bt2
._UserSinkComponent
):
575 def __init__(comp_self
, params
):
576 comp_self
._add
_input
_port
('clear')
577 comp_self
._add
_input
_port
('print')
578 comp_self
._add
_input
_port
('insert')
583 comp
= self
._create
_comp
(MySink
)
584 self
.assertEqual(len(comp
.input_ports
), 3)
586 def test_gen_src_output_ports_iter(self
):
587 class MyIter(bt2
._UserMessageIterator
):
595 class MySource(bt2
._UserSourceComponent
,
596 message_iterator_class
=MyIter
):
597 def __init__(comp_self
, params
):
598 nonlocal port1
, port2
, port3
599 port1
= comp_self
._add
_output
_port
('clear')
600 port2
= comp_self
._add
_output
_port
('print')
601 port3
= comp_self
._add
_output
_port
('insert')
603 comp
= self
._create
_comp
(MySource
)
606 for port_name
, port
in comp
.output_ports
.items():
607 ports
.append((port_name
, port
))
609 self
.assertEqual(ports
[0][0], 'clear')
610 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
611 self
.assertEqual(ports
[1][0], 'print')
612 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
613 self
.assertEqual(ports
[2][0], 'insert')
614 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
619 def test_gen_flt_output_ports_iter(self
):
620 class MyIter(bt2
._UserMessageIterator
):
628 class MyFilter(bt2
._UserFilterComponent
,
629 message_iterator_class
=MyIter
):
630 def __init__(comp_self
, params
):
631 nonlocal port1
, port2
, port3
632 port1
= comp_self
._add
_output
_port
('clear')
633 port2
= comp_self
._add
_output
_port
('print')
634 port3
= comp_self
._add
_output
_port
('insert')
636 comp
= self
._create
_comp
(MyFilter
)
639 for port_name
, port
in comp
.output_ports
.items():
640 ports
.append((port_name
, port
))
642 self
.assertEqual(ports
[0][0], 'clear')
643 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
644 self
.assertEqual(ports
[1][0], 'print')
645 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
646 self
.assertEqual(ports
[2][0], 'insert')
647 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
652 def test_gen_flt_input_ports_iter(self
):
653 class MyIter(bt2
._UserMessageIterator
):
661 class MyFilter(bt2
._UserFilterComponent
,
662 message_iterator_class
=MyIter
):
663 def __init__(comp_self
, params
):
664 nonlocal port1
, port2
, port3
665 port1
= comp_self
._add
_input
_port
('clear')
666 port2
= comp_self
._add
_input
_port
('print')
667 port3
= comp_self
._add
_input
_port
('insert')
669 comp
= self
._create
_comp
(MyFilter
)
672 for port_name
, port
in comp
.input_ports
.items():
673 ports
.append((port_name
, port
))
675 self
.assertEqual(ports
[0][0], 'clear')
676 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
677 self
.assertEqual(ports
[1][0], 'print')
678 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
679 self
.assertEqual(ports
[2][0], 'insert')
680 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
685 def test_gen_sink_input_ports_iter(self
):
690 class MySink(bt2
._UserSinkComponent
):
691 def __init__(comp_self
, params
):
692 nonlocal port1
, port2
, port3
693 port1
= comp_self
._add
_input
_port
('clear')
694 port2
= comp_self
._add
_input
_port
('print')
695 port3
= comp_self
._add
_input
_port
('insert')
700 comp
= self
._create
_comp
(MySink
)
703 for port_name
, port
in comp
.input_ports
.items():
704 ports
.append((port_name
, port
))
706 self
.assertEqual(ports
[0][0], 'clear')
707 self
.assertEqual(ports
[0][1].addr
, port1
.addr
)
708 self
.assertEqual(ports
[1][0], 'print')
709 self
.assertEqual(ports
[1][1].addr
, port2
.addr
)
710 self
.assertEqual(ports
[2][0], 'insert')
711 self
.assertEqual(ports
[2][1].addr
, port3
.addr
)
717 class MySink(bt2
._UserSinkComponent
):
718 def __init__(comp_self
, params
):
719 comp_self
._add
_input
_port
('clear')
724 comp
= self
._create
_comp
(MySink
)
725 self
.assertEqual(comp
.input_ports
['clear'].name
, 'clear')
727 def test_component(self
):
728 class MySink(bt2
._UserSinkComponent
):
729 def __init__(comp_self
, params
):
730 comp_self
._add
_input
_port
('clear')
735 comp
= self
._create
_comp
(MySink
)
736 self
.assertEqual(comp
.input_ports
['clear'].component
.addr
, comp
.addr
)
738 def test_connection_none(self
):
739 class MySink(bt2
._UserSinkComponent
):
740 def __init__(comp_self
, params
):
741 comp_self
._add
_input
_port
('clear')
746 comp
= self
._create
_comp
(MySink
)
747 self
.assertIsNone(comp
.input_ports
['clear'].connection
)
749 def test_is_connected_false(self
):
750 class MySink(bt2
._UserSinkComponent
):
751 def __init__(comp_self
, params
):
752 comp_self
._add
_input
_port
('clear')
757 comp
= self
._create
_comp
(MySink
)
758 self
.assertFalse(comp
.input_ports
['clear'].is_connected
)
761 class MySink(bt2
._UserSinkComponent
):
762 def __init__(comp_self
, params
):
763 comp_self
._add
_input
_port
('clear')
768 comp
= self
._create
_comp
(MySink
)
769 self
.assertEqual(comp
.input_ports
['clear'],
770 comp
.input_ports
['clear'])
772 def test_eq_invalid(self
):
773 class MySink(bt2
._UserSinkComponent
):
774 def __init__(comp_self
, params
):
775 comp_self
._add
_input
_port
('clear')
780 comp
= self
._create
_comp
(MySink
)
781 self
.assertNotEqual(comp
.input_ports
['clear'], 23)
783 def test_disconnect_no_connection(self
):
784 class MySink(bt2
._UserSinkComponent
):
785 def __init__(comp_self
, params
):
786 port
= comp_self
._add
_input
_port
('clear')
791 comp
= self
._create
_comp
(MySink
)
792 comp
.input_ports
['clear'].disconnect()
794 def test_priv_name(self
):
795 class MySink(bt2
._UserSinkComponent
):
796 def __init__(comp_self
, params
):
797 port
= comp_self
._add
_input
_port
('clear')
798 self
.assertEqual(port
.name
, 'clear')
803 comp
= self
._create
_comp
(MySink
)
805 def test_priv_component(self
):
806 class MySink(bt2
._UserSinkComponent
):
807 def __init__(comp_self
, params
):
808 port
= comp_self
._add
_input
_port
('clear')
809 self
.assertEqual(port
.component
, comp_self
)
814 comp
= self
._create
_comp
(MySink
)
816 def test_priv_connection_none(self
):
817 class MySink(bt2
._UserSinkComponent
):
818 def __init__(comp_self
, params
):
819 port
= comp_self
._add
_input
_port
('clear')
820 self
.assertIsNone(port
.connection
)
825 comp
= self
._create
_comp
(MySink
)
827 def test_priv_is_connected_false(self
):
828 class MySink(bt2
._UserSinkComponent
):
829 def __init__(comp_self
, params
):
830 port
= comp_self
._add
_input
_port
('clear')
831 self
.assertFalse(port
.is_connected
)
836 comp
= self
._create
_comp
(MySink
)
838 def test_priv_eq(self
):
839 class MySink(bt2
._UserSinkComponent
):
840 def __init__(comp_self
, params
):
841 port
= comp_self
._add
_input
_port
('clear')
842 self
.assertEqual(port
, port
)
847 comp
= self
._create
_comp
(MySink
)
849 def test_priv_eq_invalid(self
):
850 class MySink(bt2
._UserSinkComponent
):
851 def __init__(comp_self
, params
):
852 port
= comp_self
._add
_input
_port
('clear')
853 self
.assertNotEqual(port
, 23)
858 comp
= self
._create
_comp
(MySink
)
860 def test_priv_disconnect_no_connection(self
):
861 class MySink(bt2
._UserSinkComponent
):
862 def __init__(comp_self
, params
):
863 port
= comp_self
._add
_input
_port
('clear')
869 comp
= self
._create
_comp
(MySink
)
871 def test_priv_remove_from_component(self
):
872 class MySink(bt2
._UserSinkComponent
):
873 def __init__(comp_self
, params
):
874 port
= comp_self
._add
_input
_port
('clear')
875 self
.assertEqual(len(comp_self
._input
_ports
), 1)
878 port
.remove_from_component()
881 traceback
.print_exc()
883 self
.assertEqual(len(comp_self
._input
_ports
), 0)
884 self
.assertIsNone(port
.component
)
889 comp
= self
._create
_comp
(MySink
)
This page took 0.051261 seconds and 5 git commands to generate.