Spaces:
Sleeping

studiq-backend / tests /test_pdf_export.py
StudIQ Deploy Bot
Deploy StudIQ — 2026-09-07 18:07 UTC
2026abe
Raw History Blame Contribute Delete
954 Bytes
"""Unit tests for PDF export accent color and section parsing logic."""
import pytest
from app.services.pdf_service import _subject_accent, _parse_answer_into_sections
def test_subject_accent_computer_science():
"""Verify CS subjects receive navy blue accent."""
assert _subject_accent("Data Structures and Algorithms") == "#1E3A5F"
assert _subject_accent("Python Programming") == "#1E3A5F"
def test_subject_accent_mathematics():
"""Verify Math subjects receive green accent."""
assert _subject_accent("Discrete Mathematics") == "#14532D"
def test_parse_markdown_sections():
"""Verify markdown headings and code blocks parse into structured items."""
md = "### Introduction\nThis is text.\n```python\nprint(1)\n```"
sections = _parse_answer_into_sections(md)
assert len(sections) == 3
assert sections[0]["type"] == "heading"
assert sections[1]["type"] == "text"
assert sections[2]["type"] == "code"