bt2: add user attributes property support
[babeltrace.git] / tests / bindings / python / bt2 / test_stream_class.py
index f8d6446c0fa0a39793a7651be4081138279db9fc..60b86883439319d6fb30ce78607ddb839d05410e 100644 (file)
@@ -17,7 +17,6 @@
 #
 
 import unittest
-import bt2
 from utils import run_in_component_init
 
 
@@ -47,6 +46,7 @@ class StreamClassTestCase(unittest.TestCase):
         self.assertFalse(sc.discarded_events_have_default_clock_snapshots)
         self.assertFalse(sc.supports_discarded_packets)
         self.assertFalse(sc.discarded_packets_have_default_clock_snapshots)
+        self.assertEqual(len(sc.user_attributes), 0)
 
     def test_create_name(self):
         sc = self._tc.create_stream_class(name='bozo')
@@ -90,6 +90,18 @@ class StreamClassTestCase(unittest.TestCase):
         with self.assertRaises(TypeError):
             self._tc.create_stream_class(default_clock_class=12)
 
+    def test_create_user_attributes(self):
+        sc = self._tc.create_stream_class(user_attributes={'salut': 23})
+        self.assertEqual(sc.user_attributes, {'salut': 23})
+
+    def test_create_invalid_user_attributes(self):
+        with self.assertRaises(TypeError):
+            self._tc.create_stream_class(user_attributes=object())
+
+    def test_create_invalid_user_attributes_value_type(self):
+        with self.assertRaises(TypeError):
+            self._tc.create_stream_class(user_attributes=23)
+
     def test_automatic_stream_ids(self):
         sc = self._tc.create_stream_class(assigns_automatic_stream_id=True)
         self.assertTrue(sc.assigns_automatic_stream_id)
This page took 0.027998 seconds and 4 git commands to generate.