Files

65 lines
1.9 KiB
Python
Raw Permalink Normal View History

import pytest
from app import create_app, db as _db
import config
@pytest.fixture
def app(tmp_path):
config.DATA_DIR = str(tmp_path / "data")
config.IMAGES_DIR = str(tmp_path / "data" / "images")
config.ISSUES_DIR = str(tmp_path / "data" / "issues")
config.SQLALCHEMY_DATABASE_URI = f"sqlite:///{tmp_path / 'test.db'}"
app = create_app(start_scheduler=False)
app.config["TESTING"] = True
with app.app_context():
_db.create_all()
yield app
_db.drop_all()
@pytest.fixture
def client(app):
return app.test_client()
@pytest.fixture
def db(app):
with app.app_context():
yield _db
SAMPLE_RSS_XML = """<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Plymouth Independent</title>
<item>
<title>Test Article One</title>
<link>https://example.com/article-1</link>
<dc:creator><![CDATA[Test Author]]></dc:creator>
<pubDate>Mon, 06 Apr 2026 12:00:00 +0000</pubDate>
<category><![CDATA[Government]]></category>
<guid isPermaLink="false">https://example.com/?p=1001</guid>
<content:encoded><![CDATA[
<p>First article content.</p>
<img src="https://example.com/image1.jpg" width="1024" height="768" />
]]></content:encoded>
</item>
<item>
<title>Test Article Two</title>
<link>https://example.com/article-2</link>
<dc:creator><![CDATA[Another Author]]></dc:creator>
<pubDate>Tue, 07 Apr 2026 09:00:00 +0000</pubDate>
<category><![CDATA[Culture Calendar]]></category>
<category><![CDATA[Feature]]></category>
<guid isPermaLink="false">https://example.com/?p=1002</guid>
<content:encoded><![CDATA[
<p>Second article content.</p>
]]></content:encoded>
</item>
</channel>
</rss>"""