Files
dss/tests/test_ingestion.py
Digital Production Factory 276ed71f31 Initial commit: Clean DSS implementation
Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm

Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)

Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability

Migration completed: $(date)
🤖 Clean migration with full functionality preserved
2025-12-09 18:45:48 -03:00

66 lines
1.8 KiB
Python

"""
Tests for token ingestion from various sources.
"""
import pytest
import json
from tools.ingest.css import CSSTokenSource
from tools.ingest.scss import SCSSTokenSource
from tools.ingest.json_tokens import JSONTokenSource
@pytest.mark.asyncio
async def test_css_ingestion(sample_css):
"""Test CSS custom property extraction."""
parser = CSSTokenSource()
result = await parser.extract(sample_css)
assert len(result.tokens) >= 5
assert any(t.name == "color.primary" for t in result.tokens)
assert any(t.value == "#3B82F6" for t in result.tokens)
@pytest.mark.asyncio
async def test_scss_ingestion(sample_scss):
"""Test SCSS variable extraction."""
parser = SCSSTokenSource()
result = await parser.extract(sample_scss)
assert len(result.tokens) >= 4
assert any(t.name == "primary-color" for t in result.tokens)
@pytest.mark.asyncio
async def test_json_ingestion(sample_json_tokens):
"""Test JSON token extraction (W3C format)."""
parser = JSONTokenSource()
result = await parser.extract(json.dumps(sample_json_tokens))
assert len(result.tokens) >= 6
# Check color tokens
primary_tokens = [t for t in result.tokens if "primary" in t.name]
assert len(primary_tokens) >= 2
# Check spacing tokens
spacing_tokens = [t for t in result.tokens if "spacing" in t.name]
assert len(spacing_tokens) == 3
@pytest.mark.asyncio
async def test_empty_css():
"""Test handling of empty CSS."""
parser = CSSTokenSource()
result = await parser.extract("")
assert len(result.tokens) == 0
assert result.name
@pytest.mark.asyncio
async def test_invalid_json():
"""Test handling of invalid JSON."""
parser = JSONTokenSource()
with pytest.raises(json.JSONDecodeError):
await parser.extract("invalid json{")