bt2: add user attributes property support
[babeltrace.git] / tests / bindings / python / bt2 / test_clock_class.py
index 9bc6bae7497593be6b15e7da9ccd941268b19f30..5788e80cb1cc77a46fb159d22563843b2f551093 100644 (file)
@@ -87,6 +87,7 @@ class ClockClassTestCase(unittest.TestCase):
         self.assertEqual(cc.offset, bt2.ClockClassOffset())
         self.assertTrue(cc.origin_is_unix_epoch)
         self.assertIsNone(cc.uuid)
+        self.assertEqual(len(cc.user_attributes), 0)
 
     def test_create_name(self):
         def f(comp_self):
@@ -198,6 +199,25 @@ class ClockClassTestCase(unittest.TestCase):
 
         self.assertRaisesInComponentInit(TypeError, f)
 
+    def test_create_user_attributes(self):
+        def f(comp_self):
+            return comp_self._create_clock_class(user_attributes={'salut': 23})
+
+        cc = run_in_component_init(f)
+        self.assertEqual(cc.user_attributes, {'salut': 23})
+
+    def test_create_invalid_user_attributes(self):
+        def f(comp_self):
+            return comp_self._create_clock_class(user_attributes=object())
+
+        self.assertRaisesInComponentInit(TypeError, f)
+
+    def test_create_invalid_user_attributes_value_type(self):
+        def f(comp_self):
+            return comp_self._create_clock_class(user_attributes=23)
+
+        self.assertRaisesInComponentInit(TypeError, f)
+
 
 class ClockSnapshotTestCase(unittest.TestCase):
     def setUp(self):
This page took 0.023964 seconds and 4 git commands to generate.