1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2019 EfficiOS Inc.
10 class _DummySink(bt2
._UserSinkComponent
):
11 def _user_consume(self
):
15 class ComponentDescriptorTestCase(unittest
.TestCase
):
18 self
._comp
_descr
= bt2
.ComponentDescriptor(_DummySink
, {'zoom': -23}, self
._obj
)
20 def _get_comp_cls_from_plugin(self
):
21 plugin
= bt2
.find_plugin('text', find_in_user_dir
=False, find_in_sys_dir
=False)
22 assert plugin
is not None
23 cc
= plugin
.source_component_classes
['dmesg']
27 def test_init_invalid_cls_type(self
):
28 with self
.assertRaises(TypeError):
29 bt2
.ComponentDescriptor(int)
31 def test_init_invalid_params_type(self
):
32 with self
.assertRaises(TypeError):
33 bt2
.ComponentDescriptor(_DummySink
, object())
35 def test_init_invalid_obj_non_python_comp_cls(self
):
36 cc
= self
._get
_comp
_cls
_from
_plugin
()
38 with self
.assertRaises(ValueError):
39 bt2
.ComponentDescriptor(cc
, obj
=57)
41 def test_init_with_user_comp_cls(self
):
42 bt2
.ComponentDescriptor(_DummySink
)
44 def test_init_with_gen_comp_cls(self
):
45 cc
= self
._get
_comp
_cls
_from
_plugin
()
46 bt2
.ComponentDescriptor(cc
)
48 def test_attr_component_class(self
):
49 self
.assertIs(self
._comp
_descr
.component_class
, _DummySink
)
51 def test_attr_params(self
):
52 self
.assertEqual(self
._comp
_descr
.params
, {'zoom': -23})
54 def test_attr_obj(self
):
55 self
.assertIs(self
._comp
_descr
.obj
, self
._obj
)
58 if __name__
== '__main__':
This page took 0.049289 seconds and 4 git commands to generate.