diff --git a/tests/integration/pyramid_tests.py b/tests/integration/pyramid_tests.py index ceebff3fd..c4b9c87e4 100644 --- a/tests/integration/pyramid_tests.py +++ b/tests/integration/pyramid_tests.py @@ -115,15 +115,15 @@ def _register_mock(context, server_span): @mock.patch("random.getrandbits") def test_no_trace_headers(self, getrandbits): - getrandbits.return_value = 1234 + getrandbits.return_value = 3735928559 self.test_app.get("/example") self.assertEqual(self.observer.on_server_span_created.call_count, 1) context, server_span = self.observer.on_server_span_created.call_args[0] - self.assertEqual(server_span.trace_id, "1234") + self.assertEqual(server_span.trace_id, "0" * 24 + "DEADBEEF") self.assertEqual(server_span.parent_id, None) - self.assertEqual(server_span.id, "1234") + self.assertEqual(server_span.id, "0" * 8 + "DEADBEEF") self.assertTrue(self.server_observer.on_start.called) self.assertTrue(self.server_observer.on_finish.called) @@ -222,7 +222,7 @@ def test_exception_in_exception_view_caught(self): @mock.patch("random.getrandbits") def test_distrust_headers(self, getrandbits): - getrandbits.return_value = 9999 + getrandbits.return_value = 3735928559 self.baseplate_configurator.header_trust_handler.trust_headers = False self.test_app.get( @@ -230,9 +230,9 @@ def test_distrust_headers(self, getrandbits): ) context, server_span = self.observer.on_server_span_created.call_args[0] - self.assertEqual(server_span.trace_id, str(getrandbits.return_value)) + self.assertEqual(server_span.trace_id, "0" * 24 + "DEADBEEF") self.assertEqual(server_span.parent_id, None) - self.assertEqual(server_span.id, str(getrandbits.return_value)) + self.assertEqual(server_span.id, "0" * 8 + "DEADBEEF") def test_local_trace_in_context(self): self.test_app.get("/trace_context") diff --git a/tests/integration/tracing_tests.py b/tests/integration/tracing_tests.py index 7c00f781e..0ad0c8be9 100644 --- a/tests/integration/tracing_tests.py +++ b/tests/integration/tracing_tests.py @@ -90,7 +90,7 @@ def test_trace_on_inbound_request(self): span = self.server_span_observer._serialize() self.assertEqual(span["name"], "example") self.assertEqual(len(span["annotations"]), 2) - self.assertEqual(span["parentId"], 0) + self.assertFalse("parentId" in span) def test_local_tracing_embedded(self): with mock.patch.object( diff --git a/tests/unit/observers/tracing_tests.py b/tests/unit/observers/tracing_tests.py index 3f9fdfaad..b0e9fb458 100644 --- a/tests/unit/observers/tracing_tests.py +++ b/tests/unit/observers/tracing_tests.py @@ -245,10 +245,10 @@ def test_to_span_obj_sets_parent_id(self): span_obj = self.test_span_observer._to_span_obj([], []) self.assertEqual(span_obj["parentId"], self.span.parent_id) - def test_to_span_obj_sets_default_parent_id(self): + def test_to_span_obj_default_no_parent_id(self): self.span.parent_id = None span_obj = self.test_span_observer._to_span_obj([], []) - self.assertEqual(span_obj["parentId"], 0) + self.assertFalse("parentId" in span_obj) def test_incr_tag_adds_binary_annotation(self): self.test_span_observer.binary_annotations = []