mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 19:43:15 +00:00
Applies the plan's C5 step: git mv every test per the domain-reorg
move-map (movemap-m50.txt) into tests/{agent,analyzer,auth,dashboard,
github,middleware,models,reviewer,sandbox,slack,tools,webhooks}/, plus
the 13 fork-only placements from the scoping report §2c (Atlassian
webhook tests -> tests/webhooks/, test_atlassian_connect.py and
test_auth_error_leak.py -> tests/auth/, jira/confluence util tests ->
tests/tools/, test_repo_binding_isolation.py -> tests/sandbox/,
bot-identity/autofix tests -> tests/github/).
Path-only move: the only content edits are parents[1] -> parents[2]
fixes in test_e2b_integration.py and test_daytona_integration.py,
required because their __file__-relative ROOT path gained one more
directory level in the move.
Monkeypatch retargets for these files were already completed in C4;
none remained outstanding here.
154 lines
5.3 KiB
Python
154 lines
5.3 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from agent.dashboard.team_settings import (
|
|
DEFAULT_ORG_REVIEW_GUIDELINES,
|
|
ORG_GUIDELINES_MAX_CHARS,
|
|
REVIEW_TRACING_PROJECT_MAX_CHARS,
|
|
TeamSettingsUpdate,
|
|
_default_settings,
|
|
get_org_review_guidelines,
|
|
get_team_default_model,
|
|
get_team_review_tracing_project,
|
|
)
|
|
|
|
_AGENT_PAIR = ("bedrock_converse:us.anthropic.claude-opus-4-8", "high")
|
|
_CHAT_PAIR = ("fireworks:accounts/fireworks/models/kimi-k2p7-code", "low")
|
|
|
|
|
|
def test_org_guidelines_blank_normalizes_to_none() -> None:
|
|
assert TeamSettingsUpdate(org_guidelines=" ").org_guidelines is None
|
|
assert TeamSettingsUpdate(org_guidelines=None).org_guidelines is None
|
|
|
|
|
|
def test_org_guidelines_trimmed() -> None:
|
|
update = TeamSettingsUpdate(org_guidelines=" Flag CI gate removals.\n")
|
|
assert update.org_guidelines == "Flag CI gate removals."
|
|
|
|
|
|
def test_org_guidelines_rejects_oversized() -> None:
|
|
with pytest.raises(ValidationError):
|
|
TeamSettingsUpdate(org_guidelines="x" * (ORG_GUIDELINES_MAX_CHARS + 1))
|
|
|
|
|
|
def test_default_settings_seed_sea_haven_org_guidelines() -> None:
|
|
# Unset org guidelines default to the baked Sea Haven review baseline so the
|
|
# reviewer applies it on every repo until an admin overrides it.
|
|
assert _default_settings()["org_guidelines"] == DEFAULT_ORG_REVIEW_GUIDELINES
|
|
assert "Sea Haven review baseline" in DEFAULT_ORG_REVIEW_GUIDELINES
|
|
assert len(DEFAULT_ORG_REVIEW_GUIDELINES) <= ORG_GUIDELINES_MAX_CHARS
|
|
|
|
|
|
def test_review_tracing_project_blank_normalizes_to_none() -> None:
|
|
assert TeamSettingsUpdate(review_tracing_project=" ").review_tracing_project is None
|
|
assert TeamSettingsUpdate(review_tracing_project=None).review_tracing_project is None
|
|
|
|
|
|
def test_review_tracing_project_trimmed() -> None:
|
|
update = TeamSettingsUpdate(review_tracing_project=" pajuha\n")
|
|
assert update.review_tracing_project == "pajuha"
|
|
|
|
|
|
def test_review_tracing_project_rejects_oversized() -> None:
|
|
with pytest.raises(ValidationError):
|
|
TeamSettingsUpdate(review_tracing_project="x" * (REVIEW_TRACING_PROJECT_MAX_CHARS + 1))
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_team_review_tracing_project_returns_trimmed_text() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value={"review_tracing_project": " pajuha\n"},
|
|
):
|
|
assert await get_team_review_tracing_project() == "pajuha"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_org_review_guidelines_returns_trimmed_text() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value={"org_guidelines": " Always check auth.\n"},
|
|
):
|
|
assert await get_org_review_guidelines() == "Always check auth."
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_org_review_guidelines_returns_none_when_unset() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value={"org_guidelines": None},
|
|
):
|
|
assert await get_org_review_guidelines() is None
|
|
|
|
|
|
def _settings(**overrides: object) -> dict[str, object]:
|
|
base = {
|
|
"default_agent_model": _AGENT_PAIR[0],
|
|
"default_agent_reasoning_effort": _AGENT_PAIR[1],
|
|
"default_chat_model": None,
|
|
"default_chat_reasoning_effort": None,
|
|
}
|
|
base.update(overrides)
|
|
return base
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_chat_default_inherits_agent_when_unset() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value=_settings(),
|
|
):
|
|
assert await get_team_default_model("chat") == _AGENT_PAIR
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_chat_default_uses_chat_model_when_set() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value=_settings(
|
|
default_chat_model=_CHAT_PAIR[0],
|
|
default_chat_reasoning_effort=_CHAT_PAIR[1],
|
|
),
|
|
):
|
|
assert await get_team_default_model("chat") == _CHAT_PAIR
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_chat_default_inherits_agent_when_chat_model_invalid() -> None:
|
|
with patch(
|
|
"agent.dashboard.team_settings.get_team_settings",
|
|
new_callable=AsyncMock,
|
|
return_value=_settings(
|
|
default_chat_model="bogus:model",
|
|
default_chat_reasoning_effort="high",
|
|
),
|
|
):
|
|
assert await get_team_default_model("chat") == _AGENT_PAIR
|
|
|
|
|
|
def test_team_settings_update_accepts_chat_pair() -> None:
|
|
update = TeamSettingsUpdate(
|
|
default_chat_model=_CHAT_PAIR[0],
|
|
default_chat_reasoning_effort=_CHAT_PAIR[1],
|
|
)
|
|
assert update.default_chat_model == _CHAT_PAIR[0]
|
|
assert update.default_chat_reasoning_effort == _CHAT_PAIR[1]
|
|
|
|
|
|
def test_team_settings_update_rejects_chat_effort_without_model() -> None:
|
|
with pytest.raises(ValidationError):
|
|
TeamSettingsUpdate(default_chat_reasoning_effort="high")
|
|
|
|
|
|
def test_team_settings_update_rejects_unsupported_chat_effort() -> None:
|
|
with pytest.raises(ValidationError):
|
|
TeamSettingsUpdate(default_chat_model=_CHAT_PAIR[0], default_chat_reasoning_effort="max")
|