""" Integration tests for feed route endpoints Tests the /feed, /feed.rss, /feed.atom, /feed.json, and /feed.xml endpoints including content negotiation. """ import pytest from starpunk import create_app from starpunk.notes import create_note @pytest.fixture def app(tmp_path): """Create and configure a test app instance""" test_data_dir = tmp_path / "data" test_data_dir.mkdir(parents=True, exist_ok=True) test_config = { "TESTING": True, "DATABASE_PATH": test_data_dir / "starpunk.db", "DATA_PATH": test_data_dir, "NOTES_PATH": test_data_dir / "notes", "SESSION_SECRET": "test-secret-key", "ADMIN_ME": "https://test.example.com", "SITE_URL": "https://example.com", "SITE_NAME": "Test Site", "SITE_DESCRIPTION": "Test Description", "AUTHOR_NAME": "Test Author", "DEV_MODE": False, "FEED_CACHE_SECONDS": 0, # Disable caching for tests "FEED_MAX_ITEMS": 50, } app = create_app(config=test_config) # Create test notes with app.app_context(): create_note(content='Test content 1', published=True, custom_slug='test-note-1') create_note(content='Test content 2', published=True, custom_slug='test-note-2') yield app @pytest.fixture def client(app): """Test client for making requests""" return app.test_client() @pytest.fixture(autouse=True) def clear_feed_cache(): """Clear feed cache before each test""" from starpunk.routes import public public._feed_cache["notes"] = None public._feed_cache["timestamp"] = None yield # Clear again after test public._feed_cache["notes"] = None public._feed_cache["timestamp"] = None class TestExplicitEndpoints: """Tests for explicit format endpoints""" def test_feed_rss_endpoint(self, client): """GET /feed.rss returns RSS feed""" response = client.get('/feed.rss') assert response.status_code == 200 assert response.headers['Content-Type'] == 'application/rss+xml; charset=utf-8' assert b'' in response.data assert b'' in response.data assert b'' in response.data assert b'' in response.data