- pyproject.toml: add [tool.ruff] config suppressing E402/W293 globally, F841/E741/E702 in tests, E741 in scripts - inventory.py: split semicolon import (E702) - recipes.py: fix logger -> log (F821 undefined name) - shopping.py: rename l -> lnk in list comprehension (E741) - format_conversion.py: noqa F841 on CUDA flag (used as future hook) - backfill_keywords.py: rename done -> _done (F841) - ingest_purplecarrot.py: drop == True comparison (E712) - Auto-fix: I001 import sorting, F401 unused imports across all files
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
# tests/services/community/test_ap_compat.py
|
|
from datetime import datetime, timezone
|
|
|
|
from app.services.community.ap_compat import post_to_ap_json_ld
|
|
|
|
POST = {
|
|
"slug": "kiwi-plan-test-pasta-week",
|
|
"title": "Pasta Week",
|
|
"description": "Seven days of carbs",
|
|
"published": datetime(2026, 4, 12, 12, 0, 0, tzinfo=timezone.utc),
|
|
"pseudonym": "PastaWitch",
|
|
"dietary_tags": ["vegetarian"],
|
|
}
|
|
|
|
|
|
def test_ap_json_ld_context():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
assert doc["@context"] == "https://www.w3.org/ns/activitystreams"
|
|
|
|
|
|
def test_ap_json_ld_type():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
assert doc["type"] == "Note"
|
|
|
|
|
|
def test_ap_json_ld_id_is_uri():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
assert doc["id"].startswith("https://")
|
|
assert POST["slug"] in doc["id"]
|
|
|
|
|
|
def test_ap_json_ld_published_is_iso8601():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
from datetime import datetime
|
|
datetime.fromisoformat(doc["published"].replace("Z", "+00:00"))
|
|
|
|
|
|
def test_ap_json_ld_attributed_to_pseudonym():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
assert doc["attributedTo"] == "PastaWitch"
|
|
|
|
|
|
def test_ap_json_ld_tags_include_kiwi():
|
|
doc = post_to_ap_json_ld(POST, base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
tag_names = [t["name"] for t in doc.get("tag", [])]
|
|
assert "#kiwi" in tag_names
|