feat: remove OpenCode assistant mode
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Removed assistant types must fail cleanly without changing stored data."""
|
||||
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from fastapi import HTTPException
|
||||
from pydantic import ValidationError
|
||||
|
||||
from routes.assistants import duplicate_assistant, get_assistant
|
||||
from schemas import AssistantUpsert
|
||||
|
||||
|
||||
class AssistantTypeTests(unittest.TestCase):
|
||||
def test_removed_type_is_rejected(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
AssistantUpsert(name="旧助手", type="opencode")
|
||||
|
||||
def test_remaining_types_can_be_created(self):
|
||||
for assistant_type in ("prompt", "workflow", "dify", "fastgpt"):
|
||||
with self.subTest(type=assistant_type):
|
||||
assistant = AssistantUpsert(name="助手", type=assistant_type)
|
||||
self.assertEqual(assistant.type, assistant_type)
|
||||
|
||||
|
||||
class RetiredAssistantTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_old_record_returns_gone_without_writes(self):
|
||||
for operation in (get_assistant, duplicate_assistant):
|
||||
with self.subTest(operation=operation.__name__):
|
||||
session = AsyncMock()
|
||||
session.get.return_value = SimpleNamespace(type="opencode")
|
||||
with self.assertRaises(HTTPException) as error:
|
||||
await operation("legacy_assistant", session)
|
||||
self.assertEqual(error.exception.status_code, 410)
|
||||
session.execute.assert_not_called()
|
||||
session.add.assert_not_called()
|
||||
session.commit.assert_not_called()
|
||||
session.delete.assert_not_called()
|
||||
@@ -185,7 +185,7 @@ class BrainRegistryTests(unittest.TestCase):
|
||||
|
||||
def test_unknown_brain_does_not_fallback_to_prompt(self):
|
||||
with self.assertRaisesRegex(ValueError, "尚未实现"):
|
||||
build_brain(AssistantConfig(type="opencode"))
|
||||
build_brain(AssistantConfig(type="unknown"))
|
||||
|
||||
def test_workflow_realtime_is_accepted_at_schema_boundary(self):
|
||||
assistant = AssistantUpsert(
|
||||
|
||||
Reference in New Issue
Block a user