FastAPI + SQLite backend with vanilla-JS web UI. Requests via Open Library / Audible / AniList metadata search (or manual entry) with per-request target library selection. Manual import flow: scan the download dir, fuzzy-match files against missing requests, review, then move+rename into the library per configurable naming templates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1016 B
Python
34 lines
1016 B
Python
from types import SimpleNamespace
|
|
|
|
from wordarr.naming import render_template, sanitize
|
|
|
|
|
|
def req(**kw):
|
|
base = dict(title="", authors="", year=None, series="", volume=None)
|
|
base.update(kw)
|
|
return SimpleNamespace(**base)
|
|
|
|
|
|
def test_sanitize_removes_forbidden_chars():
|
|
assert sanitize('A<b>:c/d\\e|f?g*h"') == "Abcdefgh"
|
|
|
|
|
|
def test_ebook_template():
|
|
r = req(title="The Hobbit", authors="J.R.R. Tolkien", year=1937)
|
|
assert render_template("{Author}/{Title} ({Year})", r) == "J.R.R. Tolkien/The Hobbit (1937)"
|
|
|
|
|
|
def test_missing_year_drops_parens():
|
|
r = req(title="The Hobbit", authors="Tolkien")
|
|
assert render_template("{Title} ({Year})", r) == "The Hobbit"
|
|
|
|
|
|
def test_comic_template():
|
|
r = req(title="One Piece", series="One Piece", volume=3)
|
|
assert render_template("{Series}/{Series} - Band {Volume}", r) == "One Piece/One Piece - Band 03"
|
|
|
|
|
|
def test_first_author_only():
|
|
r = req(title="X", authors="Alice A, Bob B")
|
|
assert render_template("{Author}", r) == "Alice A"
|