import pytest

from aiservice.common_utils import parse_python_version, validate_trace_id


def test_python_version() -> None:
    assert parse_python_version("3.9.0") == (3, 9, 0)
    assert parse_python_version("3.12.2") == (3, 12, 2)
    with pytest.raises(ValueError):
        parse_python_version("3.9")
    with pytest.raises(AssertionError):
        parse_python_version("2.7.2")
    with pytest.raises(Exception):
        parse_python_version("hi.there.hello")
    with pytest.raises(AssertionError):
        parse_python_version("3.1231231129.23432412312312313212412131212122112")


def test_validate_trace_id() -> None:
    assert validate_trace_id("f47ac10b-58cc-4372-a567-0e02b2c3d479")
    assert validate_trace_id("f47ac10b-58cc-4372-a567-0e02b2c3EXP0")
    assert validate_trace_id("f47ac10b-58cc-4372-a567-0e02b2c3EXP1")
    assert not validate_trace_id("f47ac10b-58cc-4372-a567-0e0f2b2c3EXP0")
    assert not validate_trace_id("f47ac10b-58cc-4372-a567-0e0fc3EXP1")
    assert not validate_trace_id("f47ac10b")
