Files
roboco/tests/integration/services/test_project_autonomy_update.py
T

73 lines
2.1 KiB
Python
Raw Normal View History

2026-06-25 21:11:36 +02:00
"""Project update accepts the autonomous-maintenance opt-in fields.
The CI-watch + dep-update per-project columns must be settable through the
normal ProjectUpdate path (what the panel edit-project dialog calls), or the
operator can't opt a project in.
"""
from __future__ import annotations
2026-06-26 01:43:08 +02:00
from typing import TYPE_CHECKING, cast
from uuid import UUID, uuid4
2026-06-25 21:11:36 +02:00
import pytest
from roboco.db.tables import AgentTable, ProjectTable
from roboco.models import AgentRole, AgentStatus, Team
from roboco.models.project import ProjectUpdate
from roboco.services.project import get_project_service
if TYPE_CHECKING:
from sqlalchemy.ext.asyncio import AsyncSession
async def _seed_project(db_session: AsyncSession) -> ProjectTable:
agent = AgentTable(
id=uuid4(),
name="Dev",
slug=f"be-dev-{uuid4().hex[:8]}",
role=AgentRole.DEVELOPER,
team=Team.BACKEND,
status=AgentStatus.ACTIVE,
model_config={},
system_prompt="dev",
capabilities=[],
permissions={},
metrics={},
)
db_session.add(agent)
await db_session.flush()
project = ProjectTable(
id=uuid4(),
name="P",
slug=f"p-{uuid4().hex[:8]}",
git_url="https://example.com/r.git",
assigned_cell=Team.BACKEND,
created_by=agent.id,
)
db_session.add(project)
await db_session.flush()
return project
@pytest.mark.asyncio
async def test_update_sets_autonomy_opt_ins(db_session: AsyncSession) -> None:
project = await _seed_project(db_session)
svc = get_project_service(db_session)
await svc.update(
2026-06-26 01:43:08 +02:00
cast("UUID", project.id),
2026-06-25 21:11:36 +02:00
ProjectUpdate(
ci_watch_enabled=True,
ci_watch_workflow="ci.yml",
dep_update_command="uv lock --upgrade",
dep_update_paths=["uv.lock"],
),
)
2026-06-26 01:43:08 +02:00
reloaded = await svc.get(cast("UUID", project.id))
2026-06-25 21:11:36 +02:00
assert reloaded is not None
assert reloaded.ci_watch_enabled is True
assert reloaded.ci_watch_workflow == "ci.yml"
assert reloaded.dep_update_command == "uv lock --upgrade"
assert reloaded.dep_update_paths == ["uv.lock"]