from cancontech_tracing.utils import build_traceparent_header


class MockSpanContext:
    def __init__(self, trace_id, span_id):
        self.trace_id = trace_id
        self.span_id = span_id


class MockSpan:
    def __init__(self, trace_id, span_id):
        self.span_context = MockSpanContext(trace_id, span_id)

    def get_span_context(self):
        return self.span_context


def test_build_traceparent_header():
    trace_id = 132856385406875048866580800747095135959
    span_id = 17311902127830301284

    span = MockSpan(trace_id=trace_id, span_id=span_id)

    expected_header = "00-63f335874da807a3bfec17d1412b16d7-f0403b434ba77a64-01"
    assert build_traceparent_header(span) == expected_header
