dcad514eb902a75a44286fbf6226ac3a8f75fc35
1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2019 EfficiOS Inc.
11 class _DummySink(bt2
._UserSinkComponent
):
12 def _user_consume(self
):
16 class ComponentDescriptorTestCase(unittest
.TestCase
):
19 self
._comp
_descr
= bt2
.ComponentDescriptor(_DummySink
, {"zoom": -23}, self
._obj
)
21 def _get_comp_cls_from_plugin(self
):
22 plugin
= bt2
.find_plugin("text", find_in_user_dir
=False, find_in_sys_dir
=False)
23 assert plugin
is not None
24 cc
= plugin
.source_component_classes
["dmesg"]
28 def test_init_invalid_cls_type(self
):
29 with self
.assertRaises(TypeError):
30 bt2
.ComponentDescriptor(int)
32 def test_init_invalid_params_type(self
):
33 with self
.assertRaises(TypeError):
34 bt2
.ComponentDescriptor(_DummySink
, object())
36 def test_init_invalid_obj_non_python_comp_cls(self
):
37 cc
= self
._get
_comp
_cls
_from
_plugin
()
39 with self
.assertRaises(ValueError):
40 bt2
.ComponentDescriptor(cc
, obj
=57)
42 def test_init_with_user_comp_cls(self
):
43 bt2
.ComponentDescriptor(_DummySink
)
45 def test_init_with_gen_comp_cls(self
):
46 cc
= self
._get
_comp
_cls
_from
_plugin
()
47 bt2
.ComponentDescriptor(cc
)
49 def test_attr_component_class(self
):
50 self
.assertIs(self
._comp
_descr
.component_class
, _DummySink
)
52 def test_attr_params(self
):
53 self
.assertEqual(self
._comp
_descr
.params
, {"zoom": -23})
55 def test_attr_obj(self
):
56 self
.assertIs(self
._comp
_descr
.obj
, self
._obj
)
59 if __name__
== "__main__":
This page took 0.030601 seconds and 4 git commands to generate.