ppt-tool/backend/tests/test_slide_mapping.py
Vadym Samoilenko bdf6e4b4d0 Fix Docker build, test suite, and runtime issues for local deployment
- Fix UV index strategy: mark PyTorch CPU index as explicit with name
- Add --index-strategy unsafe-best-match to Dockerfile uv pip install
- Fix redis version constraint (>=5.0,<6) for ARQ compatibility
- Fix Anthropic model name (claude-sonnet-4-5-20250929)
- Fix IMAGE_PROVIDER enum value (gemini_flash, not google)
- Resolve middlewares.py vs middlewares/ package conflict
- Fix worker import paths (models.sql.presentation, models.sql.slide, utils split)
- Fix seed script FK resolution by importing all related models
- Fix test suite: async fixture scoping, greenlet dep, regex patterns, fixture params
- Fix frontend TypeScript error (Boolean cast for layout.react_code)
- Regenerate package-lock.json with i18n packages
- Add initial Alembic migration (autogenerated from all models)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:56:30 +00:00

51 lines
1.9 KiB
Python

"""Tests for slide mapping block-to-layout type logic.
Uses a duplicated mapping dict to avoid importing the full service module
(which has heavy transitive deps via google.genai).
Must stay in sync with services/slide_mapping_engine.py.
"""
# Duplicated from models/content_models.py
BLOCK_TYPES = [
"narrative", "quote", "metric", "table", "timeline",
"comparison", "list_items", "image_reference", "call_to_action",
]
# Duplicated from services/slide_mapping_engine.py
_BLOCK_TO_LAYOUT_TYPE = {
"metric": ["metrics", "kpi", "data", "chart", "content"],
"quote": ["quote", "testimonial", "content"],
"table": ["table", "chart", "data", "content"],
"timeline": ["timeline", "process", "content"],
"comparison": ["comparison", "two_column", "content"],
"list_items": ["content", "bullet", "list"],
"narrative": ["content", "text", "description"],
"image_reference": ["picture", "image", "content"],
"call_to_action": ["content", "title_slide"],
}
class TestBlockToLayoutMapping:
def test_all_block_types_have_mappings(self):
for bt in BLOCK_TYPES:
assert bt in _BLOCK_TO_LAYOUT_TYPE, (
f"ContentBlockType.{bt} missing from _BLOCK_TO_LAYOUT_TYPE"
)
def test_metric_prefers_metrics_layout(self):
assert _BLOCK_TO_LAYOUT_TYPE["metric"][0] == "metrics"
def test_quote_prefers_quote_layout(self):
assert _BLOCK_TO_LAYOUT_TYPE["quote"][0] == "quote"
def test_table_prefers_table_layout(self):
assert _BLOCK_TO_LAYOUT_TYPE["table"][0] == "table"
def test_timeline_prefers_timeline_layout(self):
assert _BLOCK_TO_LAYOUT_TYPE["timeline"][0] == "timeline"
def test_every_mapping_has_content_fallback(self):
for bt, layouts in _BLOCK_TO_LAYOUT_TYPE.items():
assert "content" in layouts, (
f"ContentBlockType.{bt} has no 'content' fallback in layout mapping"
)