# RSS Title Deduplication Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Keep each Dzen article title in the RSS `
` metadata while removing the feed-generated duplicate `` from `content:encoded`.
**Architecture:** Keep the existing `render_article_html(..., rss_safe=True)` pipeline as the sole producer of the RSS article body. Add one focused integration-style unit test using an in-memory SQLite database to exercise the real feed query and inspect the generated XML.
**Tech Stack:** Python 3, SQLAlchemy, `unittest`, `xml.etree.ElementTree`
---
### Task 1: Remove the generated RSS body heading
**Files:**
- Create: `tests/test_rss.py`
- Modify: `app/rss.py:204`
- [ ] **Step 1: Write the failing regression test**
Create `tests/test_rss.py`:
```python
import unittest
from datetime import datetime, timedelta, timezone
from xml.etree import ElementTree
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from app.config import Settings
from app.database import Base
from app.models import Article
from app.rss import build_feed_xml
class RssFeedTest(unittest.TestCase):
def test_article_title_is_metadata_only_not_generated_body_heading(self):
engine = create_engine("sqlite:///:memory:")
Base.metadata.create_all(engine)
article = Article(
slug="test-article",
title="Тестовый заголовок",
lead="
Тестовый лид.
",
body_html="Основной текст.
",
cta_html="",
feature_image_url="",
status="published",
rss_guid="test-guid",
published_at=datetime.now(timezone.utc) - timedelta(minutes=1),
)
with Session(engine) as session:
session.add(article)
session.commit()
xml = build_feed_xml(session, Settings(public_base_url="https://example.test"))
root = ElementTree.fromstring(xml)
item = root.find("./channel/item")
self.assertIsNotNone(item)
self.assertEqual(item.findtext("title"), "Тестовый заголовок")
content = item.findtext("{http://purl.org/rss/1.0/modules/content/}encoded") or ""
self.assertNotIn("Тестовый заголовок
", content)
self.assertIn("Тестовый лид.
", content)
self.assertIn("Основной текст.
", content)
if __name__ == "__main__":
unittest.main()
```
- [ ] **Step 2: Run the focused test and verify the current behavior fails**
Run:
```bash
docker run --rm \
-e PYTHONPYCACHEPREFIX=/tmp/pycache \
-v "$PWD:/workspace:ro" \
-w /workspace \
dzen-assistant-test:local \
python -m unittest tests.test_rss -v
```
Expected: one failure because `content:encoded` contains `Тестовый заголовок
`.
- [ ] **Step 3: Use the existing renderer as the complete RSS body**
In `app/rss.py`, replace the body construction inside `build_feed_xml` with:
```python
content = render_article_html(article, rss_safe=True)
```
Do not change the item ``, cover caption, description, or article page renderer.
- [ ] **Step 4: Run the focused test and verify it passes**
Run the command from Step 2.
Expected: `Ran 1 test` followed by `OK`.
- [ ] **Step 5: Run the backend regression suite and compilation**
Run:
```bash
docker run --rm \
-e PYTHONPYCACHEPREFIX=/tmp/pycache \
-v "$PWD:/workspace:ro" \
-w /workspace \
dzen-assistant-test:local \
python -m unittest discover -s tests -v
docker run --rm \
-e PYTHONPYCACHEPREFIX=/tmp/pycache \
-v "$PWD:/workspace:ro" \
-w /workspace \
dzen-assistant-test:local \
python -m compileall -q app tests
```
Expected: all tests pass and compilation exits with status 0.
- [ ] **Step 6: Commit the implementation**
```bash
git add app/rss.py tests/test_rss.py
git commit -m "fix: avoid duplicate article titles in RSS bodies"
```