def test_span_id_limit(self): traceparent = BaseTraceparent(span_id=b'\0\0\0\0\0\0\0\0') self.assertEqual(traceparent.span_id, b'\0\0\0\0\0\0\0\0') self.assertRaises(ValueError, lambda: BaseTraceparent(span_id=b'\0\0\0\0\0\0\0')) self.assertRaises( ValueError, lambda: BaseTraceparent(span_id=b'\0\0\0\0\0\0\0\0\0'))
def test_version_limit(self): traceparent = BaseTraceparent(version=0) self.assertEqual(traceparent.version, 0) traceparent = BaseTraceparent(version=254) self.assertEqual(traceparent.version, 254) self.assertRaises(ValueError, lambda: BaseTraceparent(version=-1)) self.assertRaises(ValueError, lambda: BaseTraceparent(version=255))
def test_trace_flags_limit(self): traceparent = BaseTraceparent(trace_flags = 0) self.assertEqual(traceparent.trace_flags, 0) traceparent = BaseTraceparent(trace_flags = 0xff) self.assertEqual(traceparent.trace_flags, 0xff) self.assertRaises(ValueError, lambda: BaseTraceparent(trace_flags = -1)) self.assertRaises(ValueError, lambda: BaseTraceparent(trace_flags = 0xff + 1))
def test_ctor_default(self): traceparent = BaseTraceparent() self.assertEqual(traceparent.version, 0) self.assertEqual(traceparent.trace_id, b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0') self.assertEqual(traceparent.span_id, b'\0\0\0\0\0\0\0\0') self.assertEqual(traceparent.trace_flags, 0)
def test_set_parent_id(self): traceparent = BaseTraceparent() traceparent.set_parent_id(None) traceparent.set_parent_id(b'\xff\xff\xff\xff\xff\xff\xff\xff') self.assertRaises(ValueError, lambda: traceparent.set_parent_id('fffffffffffffff')) traceparent.set_parent_id('ffffffffffffffff') self.assertRaises(ValueError, lambda: traceparent.set_parent_id('fffffffffffffffff'))
def test_ctor_with_variadic_arguments(self): traceparent = BaseTraceparent(0, None, None, 0, 'foo', 'bar', 'baz')
def test_ctor(self): self.assertRaises(ValueError, lambda: BaseTraceparent(version=0xff))