+ def test_create_source_from_user(self):
+ spec = bt2.ComponentSpec(_SomeSource)
+ self.assertEqual(spec.component_class.name, '_SomeSource')
+
+ def test_create_filter_from_name(self):
+ spec = bt2.ComponentSpec.from_named_plugin_and_component_class('utils', 'muxer')
+ self.assertEqual(spec.component_class.name, 'muxer')
+
+ def test_create_filter_from_object(self):
+ spec = bt2.ComponentSpec(self._muxer_cc)
+ self.assertEqual(spec.component_class.name, 'muxer')
+
+ def test_create_sink_from_name(self):
+ with self.assertRaisesRegex(
+ KeyError,
+ 'source or filter component class `pretty` not found in plugin `text`',
+ ):
+ bt2.ComponentSpec.from_named_plugin_and_component_class('text', 'pretty')
+
+ def test_create_sink_from_object(self):
+ with self.assertRaisesRegex(
+ TypeError, "'_SinkComponentClass' is not a source or filter component class"
+ ):
+ bt2.ComponentSpec(self._pretty_cc)
+
+ def test_create_from_object_with_params(self):
+ spec = bt2.ComponentSpec(self._dmesg_cc, {'salut': 23})
+ self.assertEqual(spec.params['salut'], 23)
+
+ def test_create_from_name_with_params(self):
+ spec = bt2.ComponentSpec.from_named_plugin_and_component_class(
+ 'text', 'dmesg', {'salut': 23}
+ )
+ self.assertEqual(spec.params['salut'], 23)
+
+ def test_create_from_object_with_path_params(self):
+ spec = spec = bt2.ComponentSpec(self._dmesg_cc, 'a path')