- 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
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# tests/services/community/test_feed.py
|
|
from datetime import datetime, timezone
|
|
|
|
from app.services.community.feed import posts_to_rss
|
|
|
|
|
|
def make_post_dict(**kwargs):
|
|
defaults = dict(
|
|
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),
|
|
post_type="plan",
|
|
pseudonym="PastaWitch",
|
|
)
|
|
defaults.update(kwargs)
|
|
return defaults
|
|
|
|
|
|
def test_rss_is_valid_xml():
|
|
import xml.etree.ElementTree as ET
|
|
rss = posts_to_rss([make_post_dict()], base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
root = ET.fromstring(rss)
|
|
assert root.tag == "rss"
|
|
assert root.attrib.get("version") == "2.0"
|
|
|
|
|
|
def test_rss_contains_item():
|
|
import xml.etree.ElementTree as ET
|
|
rss = posts_to_rss([make_post_dict()], base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
root = ET.fromstring(rss)
|
|
items = root.findall(".//item")
|
|
assert len(items) == 1
|
|
|
|
|
|
def test_rss_item_has_required_fields():
|
|
import xml.etree.ElementTree as ET
|
|
rss = posts_to_rss([make_post_dict()], base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
root = ET.fromstring(rss)
|
|
item = root.find(".//item")
|
|
assert item.find("title") is not None
|
|
assert item.find("link") is not None
|
|
assert item.find("pubDate") is not None
|
|
|
|
|
|
def test_rss_empty_posts():
|
|
import xml.etree.ElementTree as ET
|
|
rss = posts_to_rss([], base_url="https://menagerie.circuitforge.tech/kiwi")
|
|
root = ET.fromstring(rss)
|
|
items = root.findall(".//item")
|
|
assert len(items) == 0
|