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

@@ -121,7 +121,9 @@ class TestSprintUpdate:
name="Updated Sprint Name",
goal="Updated goal",
)
result = await sprint_crud.update(session, db_obj=sprint, obj_in=update_data)
result = await sprint_crud.update(
session, db_obj=sprint, obj_in=update_data
)
assert result.name == "Updated Sprint Name"
assert result.goal == "Updated goal"
@@ -139,7 +141,9 @@ class TestSprintUpdate:
start_date=today + timedelta(days=1),
end_date=today + timedelta(days=21),
)
result = await sprint_crud.update(session, db_obj=sprint, obj_in=update_data)
result = await sprint_crud.update(
session, db_obj=sprint, obj_in=update_data
)
assert result.start_date == today + timedelta(days=1)
assert result.end_date == today + timedelta(days=21)
@@ -163,7 +167,9 @@ class TestSprintLifecycle:
assert result.status == SprintStatus.ACTIVE
@pytest.mark.asyncio
async def test_start_sprint_with_custom_date(self, async_test_db, test_project_crud):
async def test_start_sprint_with_custom_date(
self, async_test_db, test_project_crud
):
"""Test starting sprint with custom start date."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -195,7 +201,9 @@ class TestSprintLifecycle:
assert result.start_date == new_start
@pytest.mark.asyncio
async def test_start_sprint_already_active_fails(self, async_test_db, test_project_crud):
async def test_start_sprint_already_active_fails(
self, async_test_db, test_project_crud
):
"""Test starting an already active sprint raises ValueError."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -250,7 +258,9 @@ class TestSprintLifecycle:
assert result.status == SprintStatus.COMPLETED
@pytest.mark.asyncio
async def test_complete_planned_sprint_fails(self, async_test_db, test_project_crud):
async def test_complete_planned_sprint_fails(
self, async_test_db, test_project_crud
):
"""Test completing a planned sprint raises ValueError."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -300,7 +310,9 @@ class TestSprintLifecycle:
assert result.status == SprintStatus.CANCELLED
@pytest.mark.asyncio
async def test_cancel_completed_sprint_fails(self, async_test_db, test_project_crud):
async def test_cancel_completed_sprint_fails(
self, async_test_db, test_project_crud
):
"""Test cancelling a completed sprint raises ValueError."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -329,7 +341,9 @@ class TestSprintByProject:
"""Tests for getting sprints by project."""
@pytest.mark.asyncio
async def test_get_by_project(self, async_test_db, test_project_crud, test_sprint_crud):
async def test_get_by_project(
self, async_test_db, test_project_crud, test_sprint_crud
):
"""Test getting sprints by project."""
_test_engine, AsyncTestingSessionLocal = async_test_db
@@ -506,7 +520,9 @@ class TestSprintWithIssueCounts:
"""Tests for getting sprints with issue counts."""
@pytest.mark.asyncio
async def test_get_sprints_with_issue_counts(self, async_test_db, test_project_crud, test_sprint_crud):
async def test_get_sprints_with_issue_counts(
self, async_test_db, test_project_crud, test_sprint_crud
):
"""Test getting sprints with issue counts."""
_test_engine, AsyncTestingSessionLocal = async_test_db