Spaces:
Sleeping
Sleeping
File size: 1,715 Bytes
2e818da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import pytest
from app.services.literature_contract import LiteratureRequest, build_deterministic_contract
def test_latest_author_request_is_singular_and_date_ranked():
result = build_deterministic_contract(
"I need the latest paper of Jonas Gehring",
LiteratureRequest(),
)
assert result.operation == "author_works"
assert result.author_names == ["Jonas Gehring"]
assert result.ranking == "publication_date"
assert result.result_limit == 1
def test_top_five_2026_by_citations_is_year_bounded():
result = build_deterministic_contract(
"What are the top 5 papers of 2026 by citation?",
LiteratureRequest(),
)
assert result.operation == "ranked_papers"
assert result.year_start == result.year_end == 2026
assert result.ranking == "citation_count"
assert result.result_limit == 5
@pytest.mark.parametrize(
("query", "direction"),
[
("top 5 papers that cite Attention Is All You Need", "cites_seed"),
("top 5 papers Attention Is All You Need cites", "cited_by_seed"),
],
)
def test_citation_direction_is_explicit(query, direction):
result = build_deterministic_contract(query, LiteratureRequest())
assert result.citation_direction == direction
assert result.result_limit == 5
assert result.ranking == "citation_count"
def test_explicit_author_constraint_survives_planner_topics():
planned = LiteratureRequest(topics=["sequence modeling"], result_limit=5)
result = build_deterministic_contract("latest paper by Jonas Gehring", planned)
assert result.author_names == ["Jonas Gehring"]
assert result.topics == ["sequence modeling"]
assert result.result_limit == 1
|