refactor: remove main session key references and enhance agent-gateway associations

This commit is contained in:
Abhimanyu Saharan
2026-02-10 02:58:58 +05:30
parent 50f71960de
commit 6f070df74b
27 changed files with 552 additions and 672 deletions

View File

@@ -1,36 +1,42 @@
# ruff: noqa
from uuid import uuid4
from app.models.agents import Agent
from app.services.mentions import extract_mentions, matches_agent_mention
def _agent(name: str, *, is_board_lead: bool = False) -> Agent:
return Agent(name=name, gateway_id=uuid4(), is_board_lead=is_board_lead)
def test_extract_mentions_parses_tokens():
assert extract_mentions("hi @Alex and @bob-2") == {"alex", "bob-2"}
def test_matches_agent_mention_matches_first_name():
agent = Agent(name="Alice Cooper")
agent = _agent("Alice Cooper")
assert matches_agent_mention(agent, {"alice"}) is True
assert matches_agent_mention(agent, {"cooper"}) is False
def test_matches_agent_mention_no_mentions_is_false():
agent = Agent(name="Alice")
agent = _agent("Alice")
assert matches_agent_mention(agent, set()) is False
def test_matches_agent_mention_empty_agent_name_is_false():
agent = Agent(name=" ")
agent = _agent(" ")
assert matches_agent_mention(agent, {"alice"}) is False
def test_matches_agent_mention_matches_full_normalized_name():
agent = Agent(name="Alice Cooper")
agent = _agent("Alice Cooper")
assert matches_agent_mention(agent, {"alice cooper"}) is True
def test_matches_agent_mention_supports_reserved_lead_shortcut():
lead = Agent(name="Riya", is_board_lead=True)
other = Agent(name="Lead", is_board_lead=False)
lead = _agent("Riya", is_board_lead=True)
other = _agent("Lead", is_board_lead=False)
assert matches_agent_mention(lead, {"lead"}) is True
assert matches_agent_mention(other, {"lead"}) is False