Files
ss-tools/backend/tests/plugins/translate/test_plugin.py
busya f75c15dbc6 test: massive coverage expansion — 15 new test modules + assistant tool fixes + orthogonal testing
- 10 translate plugin test files (100% coverage on 12 modules)
- assistant/handler tools: 85+ tests covering dispatch, registry, resolvers, routes, llm_planner, 13 tool handlers
- clean release: artifact_catalog_loader, mappers, approval, publication tests
- API routes: translate_helpers, validation_service extensions, datasets to 100%
- notifications: providers/service tests
- services: profile_preference_service
- docs/orthogonal-test-report.md — full speckit.tests audit
- Fixes: 3 git_base async mock failures, 4 assistant handler permission-check patches
- .gitignore: coverage artifacts
2026-06-15 15:38:59 +03:00

83 lines
3.0 KiB
Python

# #region Test.TranslatePlugin [C:3] [TYPE Module] [SEMANTICS test,translate,plugin,interface]
# @BRIEF Tests for plugin.py — TranslatePlugin class.
# @RELATION BINDS_TO -> [TranslatePlugin]
# @TEST_CONTRACT: properties -> str | id, name, description, version
# @TEST_CONTRACT: get_schema -> dict | JSON schema with source_dialect, target_dialect, job_id
# @TEST_CONTRACT: execute -> NotImplementedError | deferred implementation
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent / "src"))
import os
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-testing")
os.environ.setdefault("DATABASE_URL", "sqlite:///:memory:")
os.environ.setdefault("AUTH_DATABASE_URL", "sqlite:///:memory:")
import pytest
from src.plugins.translate.plugin import TranslatePlugin
class TestTranslatePlugin:
"""TranslatePlugin — metadata properties and schema."""
def setup_method(self):
self.plugin = TranslatePlugin()
def test_id(self):
"""Plugin ID is 'translate'."""
assert self.plugin.id == "translate"
def test_name(self):
"""Plugin name is 'LLM Table Translation'."""
assert self.plugin.name == "LLM Table Translation"
def test_description(self):
"""Plugin description is about cross-dialect SQL translation."""
desc = self.plugin.description
assert "Cross-dialect" in desc
assert "SQL" in desc
def test_version(self):
"""Plugin version is 1.0.0."""
assert self.plugin.version == "1.0.0"
def test_get_schema_structure(self):
"""Schema is a dict with type, properties, required."""
schema = self.plugin.get_schema()
assert isinstance(schema, dict)
assert schema["type"] == "object"
assert "properties" in schema
assert "required" in schema
def test_get_schema_contains_source_dialect(self):
"""Schema includes source_dialect string field."""
props = self.plugin.get_schema()["properties"]
assert "source_dialect" in props
assert props["source_dialect"]["type"] == "string"
def test_get_schema_contains_target_dialect(self):
"""Schema includes target_dialect string field."""
props = self.plugin.get_schema()["properties"]
assert "target_dialect" in props
assert props["target_dialect"]["type"] == "string"
def test_get_schema_contains_job_id(self):
"""Schema includes job_id string field."""
props = self.plugin.get_schema()["properties"]
assert "job_id" in props
assert props["job_id"]["type"] == "string"
def test_get_schema_required_job_id(self):
"""job_id is required."""
schema = self.plugin.get_schema()
assert "job_id" in schema["required"]
@pytest.mark.asyncio
async def test_execute_not_implemented(self):
"""execute raises NotImplementedError."""
with pytest.raises(NotImplementedError, match="not yet implemented"):
await self.plugin.execute({"job_id": "test"})
# #endregion Test.TranslatePlugin