Files
ss-tools/backend/tests/plugins/translate/test_plugin.py
root 632b730fff chore: migrate GRACE-Poly anchors to hierarchical dotted naming
Systematic rename of all semantic anchors (#region, [DEF], @RELATION)
across 1400+ files — backend Python, frontend Svelte/TS, specs, docs:
- Flat anchors become Namespace.Module.Entity
- @RELATION references updated to match new anchor paths
- Zero business logic changes
2026-07-22 11:48:15 +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 -> [Plugin.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