Manage Atom feeds in a persistent git repository
1"""Test configuration and fixtures for thicket."""
2
3import tempfile
4from pathlib import Path
5
6import pytest
7
8from thicket.models import ThicketConfig, UserConfig
9
10
11@pytest.fixture
12def temp_dir():
13 """Create a temporary directory for tests."""
14 with tempfile.TemporaryDirectory() as tmp_dir:
15 yield Path(tmp_dir)
16
17
18@pytest.fixture
19def sample_config(temp_dir):
20 """Create a sample configuration for testing."""
21 git_store = temp_dir / "git_store"
22 cache_dir = temp_dir / "cache"
23
24 return ThicketConfig(
25 git_store=git_store,
26 cache_dir=cache_dir,
27 users=[
28 UserConfig(
29 username="testuser",
30 feeds=["https://example.com/feed.xml"],
31 email="test@example.com",
32 display_name="Test User",
33 )
34 ],
35 )
36
37
38@pytest.fixture
39def sample_atom_feed():
40 """Sample Atom feed XML for testing."""
41 return """<?xml version="1.0" encoding="utf-8"?>
42<feed xmlns="http://www.w3.org/2005/Atom">
43 <title>Test Feed</title>
44 <link href="https://example.com/"/>
45 <updated>2025-01-01T00:00:00Z</updated>
46 <author>
47 <name>Test Author</name>
48 <email>author@example.com</email>
49 </author>
50 <id>https://example.com/</id>
51
52 <entry>
53 <title>Test Entry</title>
54 <link href="https://example.com/entry/1"/>
55 <id>https://example.com/entry/1</id>
56 <updated>2025-01-01T00:00:00Z</updated>
57 <summary>This is a test entry.</summary>
58 <content type="html">
59 <![CDATA[<p>This is the content of the test entry.</p>]]>
60 </content>
61 </entry>
62</feed>"""
63
64
65@pytest.fixture
66def sample_rss_feed():
67 """Sample RSS feed XML for testing."""
68 return """<?xml version="1.0" encoding="UTF-8"?>
69<rss version="2.0">
70 <channel>
71 <title>Test RSS Feed</title>
72 <link>https://example.com/</link>
73 <description>Test RSS feed for testing</description>
74 <managingEditor>editor@example.com</managingEditor>
75
76 <item>
77 <title>Test RSS Entry</title>
78 <link>https://example.com/rss/entry/1</link>
79 <description>This is a test RSS entry.</description>
80 <pubDate>Mon, 01 Jan 2025 00:00:00 GMT</pubDate>
81 <guid>https://example.com/rss/entry/1</guid>
82 </item>
83 </channel>
84</rss>"""