"""Сопоставление лейблов с командой (без БД).""" from uuid import UUID, uuid4 from onguard24.ingress.team_match import match_team_for_labels def test_match_returns_none_when_empty() -> None: assert match_team_for_labels({}, []) is None assert match_team_for_labels({"a": "b"}, []) is None def test_match_first_rule_wins_in_order() -> None: u_infra = uuid4() u_other = uuid4() labels = {"team": "infra", "env": "prod"} rules: list[tuple[UUID, str, str]] = [ (u_infra, "team", "infra"), (u_other, "env", "prod"), ] assert match_team_for_labels(labels, rules) == u_infra def test_match_skips_until_value_matches() -> None: u = uuid4() labels = {"x": "1"} rules: list[tuple[UUID, str, str]] = [ (uuid4(), "x", "2"), (u, "x", "1"), ] assert match_team_for_labels(labels, rules) == u def test_match_coerces_label_values_to_str() -> None: u = uuid4() labels = {"port": 8080} rules: list[tuple[UUID, str, str]] = [(u, "port", "8080")] assert match_team_for_labels(labels, rules) == u