Files
FabledScribe/tests/test_utils.py
T
bvandeusen e128406790 Add Forgejo Actions CI/CD, ruff linting, and test foundation
- .forgejo/workflows/ci.yml: fast checks on every push (TS typecheck,
  Python lint via ruff, pytest) — no Docker build, ~30s with cache
- .forgejo/workflows/build.yml: Docker build with registry-side layer
  caching + SSH deploy on main branch pushes only
- pyproject.toml: add ruff to dev deps, configure pytest and ruff rules
- tests/: conftest.py + first unit tests for _safe_filename (no DB needed)
- Makefile: add lint, fmt, typecheck, test, check targets for local use

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08 18:46:54 -04:00

34 lines
960 B
Python

"""
Unit tests for pure utility functions — no database or network required.
"""
import pytest
from fabledassistant.routes.export import _safe_filename
class TestSafeFilename:
def test_normal_title(self):
assert _safe_filename("My Note") == "My_Note"
def test_strips_special_chars(self):
result = _safe_filename("Hello: World! (2024)")
assert ":" not in result
assert "!" not in result
assert "(" not in result
def test_empty_title(self):
assert _safe_filename("") == "untitled"
def test_none_title(self):
assert _safe_filename(None) == "untitled"
def test_truncates_long_title(self):
long = "a" * 100
assert len(_safe_filename(long)) <= 80
def test_preserves_hyphens(self):
assert "-" in _safe_filename("my-note-title")
def test_collapses_whitespace(self):
result = _safe_filename("hello world")
assert " " not in result