research-link-ai / tests /test_slugify.py
MHamdan's picture
Deploy Research-Link-AI (Docker Space, offline demo)
a753e74 verified
Raw
History Blame Contribute Delete
1.21 kB
"""Tests for slug generation."""
from researchlink.services.slugify import make_paper_slug
def test_basic_slug():
assert make_paper_slug("Attention Is All You Need", 2017) == "2017-attention-is-all-you-need"
def test_slug_strips_subtitle():
result = make_paper_slug("MARL-IoTP: Heterogeneous Multi-Agent Learning for Perception-Aware Edge Orchestration", 2026)
assert result.startswith("2026-marl-iotp")
def test_slug_no_year():
result = make_paper_slug("Deep Reinforcement Learning")
assert result == "deep-reinforcement-learning"
assert not result.startswith("-")
def test_slug_max_length():
long_title = "A " * 40 + "Paper"
result = make_paper_slug(long_title, 2024)
assert len(result) <= 60 # year prefix (5) + 50 slug + buffer
def test_slug_special_chars():
result = make_paper_slug("BERT: Pre-training of Deep Bidirectional Transformers", 2019)
assert "bert" in result
assert ":" not in result
def test_slug_lowercase():
result = make_paper_slug("Upper Case Title", 2023)
assert result == result.lower()
def test_slug_no_double_hyphens():
result = make_paper_slug("Multi--Agent Systems", 2022)
assert "--" not in result