feat(figment): add SVG to half-block rasterization pipeline
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
47
tests/test_figment_render.py
Normal file
47
tests/test_figment_render.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""Tests for engine.figment_render module."""
|
||||
|
||||
import os
|
||||
|
||||
from engine.figment_render import rasterize_svg
|
||||
|
||||
FIXTURE_SVG = os.path.join(os.path.dirname(__file__), "fixtures", "test.svg")
|
||||
|
||||
|
||||
class TestRasterizeSvg:
|
||||
def test_returns_list_of_strings(self):
|
||||
rows = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
assert isinstance(rows, list)
|
||||
assert all(isinstance(r, str) for r in rows)
|
||||
|
||||
def test_output_height_matches_terminal_height(self):
|
||||
rows = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
assert len(rows) == 20
|
||||
|
||||
def test_output_contains_block_characters(self):
|
||||
rows = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
all_chars = "".join(rows)
|
||||
block_chars = {"█", "▀", "▄"}
|
||||
assert any(ch in all_chars for ch in block_chars)
|
||||
|
||||
def test_different_sizes_produce_different_output(self):
|
||||
rows_small = rasterize_svg(FIXTURE_SVG, 20, 10)
|
||||
rows_large = rasterize_svg(FIXTURE_SVG, 80, 40)
|
||||
assert len(rows_small) == 10
|
||||
assert len(rows_large) == 40
|
||||
|
||||
def test_nonexistent_file_raises(self):
|
||||
import pytest
|
||||
with pytest.raises(Exception):
|
||||
rasterize_svg("/nonexistent/file.svg", 40, 20)
|
||||
|
||||
|
||||
class TestRasterizeCache:
|
||||
def test_cache_returns_same_result(self):
|
||||
rows1 = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
rows2 = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
assert rows1 == rows2
|
||||
|
||||
def test_cache_invalidated_by_size_change(self):
|
||||
rows1 = rasterize_svg(FIXTURE_SVG, 40, 20)
|
||||
rows2 = rasterize_svg(FIXTURE_SVG, 60, 30)
|
||||
assert len(rows1) != len(rows2)
|
||||
Reference in New Issue
Block a user