test(backend): add comprehensive tests for OAuth and agent endpoints

- Added tests for OAuth provider admin and consent endpoints covering edge cases.
- Extended agent-related tests to handle incorrect project associations and lifecycle state transitions.
- Introduced tests for sprint status transitions and validation checks.
- Improved multiline formatting consistency across all test functions.
This commit is contained in:
2026-01-03 01:44:11 +01:00
parent acd18ff694
commit 664415111a
28 changed files with 1530 additions and 216 deletions

View File

@@ -42,7 +42,9 @@ class TestIssueCreate:
assert result.story_points == 5
@pytest.mark.asyncio
async def test_create_issue_with_external_tracker(self, async_test_db, test_project_crud):
async def test_create_issue_with_external_tracker(
self, async_test_db, test_project_crud
):
"""Test creating issue with external tracker info."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -182,7 +184,9 @@ class TestIssueAssignment:
"""Tests for issue assignment operations."""
@pytest.mark.asyncio
async def test_assign_to_agent(self, async_test_db, test_issue_crud, test_agent_instance_crud):
async def test_assign_to_agent(
self, async_test_db, test_issue_crud, test_agent_instance_crud
):
"""Test assigning issue to an agent."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -198,7 +202,9 @@ class TestIssueAssignment:
assert result.human_assignee is None
@pytest.mark.asyncio
async def test_unassign_agent(self, async_test_db, test_issue_crud, test_agent_instance_crud):
async def test_unassign_agent(
self, async_test_db, test_issue_crud, test_agent_instance_crud
):
"""Test unassigning agent from issue."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -237,7 +243,9 @@ class TestIssueAssignment:
assert result.assigned_agent_id is None
@pytest.mark.asyncio
async def test_assign_to_human_clears_agent(self, async_test_db, test_issue_crud, test_agent_instance_crud):
async def test_assign_to_human_clears_agent(
self, async_test_db, test_issue_crud, test_agent_instance_crud
):
"""Test assigning to human clears agent assignment."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -304,7 +312,9 @@ class TestIssueByProject:
"""Tests for getting issues by project."""
@pytest.mark.asyncio
async def test_get_by_project(self, async_test_db, test_project_crud, test_issue_crud):
async def test_get_by_project(
self, async_test_db, test_project_crud, test_issue_crud
):
"""Test getting issues by project."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -397,7 +407,9 @@ class TestIssueBySprint:
"""Tests for getting issues by sprint."""
@pytest.mark.asyncio
async def test_get_by_sprint(self, async_test_db, test_project_crud, test_sprint_crud):
async def test_get_by_sprint(
self, async_test_db, test_project_crud, test_sprint_crud
):
"""Test getting issues by sprint."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -533,7 +545,11 @@ class TestIssueStats:
# Create issues with various statuses and priorities
async with AsyncTestingSessionLocal() as session:
for status in [IssueStatus.OPEN, IssueStatus.IN_PROGRESS, IssueStatus.CLOSED]:
for status in [
IssueStatus.OPEN,
IssueStatus.IN_PROGRESS,
IssueStatus.CLOSED,
]:
issue_data = IssueCreate(
project_id=test_project_crud.id,
title=f"Stats Issue {status.value}",