49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from core.models import Bounds, Scene, SceneElement
|
|
from semantic.config import SemanticConfig
|
|
from semantic.enricher import enrich_scene
|
|
|
|
|
|
@pytest.mark.integration
|
|
def test_real_anthropic_semantic_enrichment_returns_schema_valid_scene() -> None:
|
|
if not os.environ.get("ANTHROPIC_API_KEY"):
|
|
pytest.skip("ANTHROPIC_API_KEY is required for semantic integration test")
|
|
try:
|
|
import anthropic # noqa: F401
|
|
except ImportError:
|
|
pytest.skip("anthropic SDK is not installed")
|
|
|
|
scene = Scene(
|
|
width=10,
|
|
height=20,
|
|
elements=[
|
|
SceneElement(
|
|
id="input",
|
|
type="input",
|
|
text="Message",
|
|
bounds=Bounds(1, 2, 3, 4),
|
|
),
|
|
SceneElement(
|
|
id="send",
|
|
type="button",
|
|
text="Send",
|
|
bounds=Bounds(5, 2, 3, 4),
|
|
),
|
|
],
|
|
)
|
|
|
|
result = enrich_scene(
|
|
scene,
|
|
config=SemanticConfig(enabled=True, timeout=10.0),
|
|
)
|
|
|
|
assert result is not None
|
|
assert result.page
|
|
assert result.intents
|
|
assert all(widget.element_id in {"input", "send"} for widget in result.widgets)
|