Skip to content

Commit e5e85fb

Browse files
committed
test: add tests for summary image removal feature
1 parent d093610 commit e5e85fb

File tree

9 files changed

+762
-16
lines changed

9 files changed

+762
-16
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ disable_error_code = ["attr-defined", "import"]
159159

160160
[tool.pytest.ini_options]
161161
pythonpath = [".", "tests"]
162+
filterwarnings = [
163+
"ignore:Inheritance class HomeAssistantApplication from web.Application is discouraged:DeprecationWarning"
164+
]
162165

163166
[tool.bumpver]
164167
current_version = "0.1.11"

tests/conftest.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,23 @@ def get_feeds() -> list[FeedSource]:
1414

1515
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
1616
"""Generate tests and fixtures."""
17+
feeds = get_feeds()
1718
if "feed" in metafunc.fixturenames:
18-
feeds = get_feeds()
1919
metafunc.parametrize("feed", feeds, ids=[f.name for f in feeds], indirect=True)
20+
if "feed_with_image_in_summary" in metafunc.fixturenames:
21+
feeds_with_image_in_summary = [
22+
pytest.param(
23+
feed,
24+
id=feed.name,
25+
)
26+
for feed in feeds
27+
if feed.has_images_in_summary
28+
]
29+
metafunc.parametrize(
30+
"feed_with_image_in_summary",
31+
feeds_with_image_in_summary,
32+
indirect=True,
33+
)
2034

2135

2236
@pytest.fixture()
@@ -29,3 +43,11 @@ def feed(request: pytest.FixtureRequest) -> FeedSource:
2943
def feed_sensor(feed: FeedSource) -> FeedParserSensor:
3044
"""Return feed sensor initialized with the local RSS feed."""
3145
return FeedParserSensor(**feed.sensor_config_local_feed)
46+
47+
48+
@pytest.fixture()
49+
def feed_with_image_in_summary(
50+
request: pytest.FixtureRequest,
51+
) -> FeedSource:
52+
"""Return feed sensor with images in summary of its entries."""
53+
return request.param

tests/constants.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
TEST_FEEDS = [
99
{
1010
"has_images": True,
11+
"has_unique_images": False,
1112
"sensor_config": {
1213
"name": "CTK",
1314
"feed_url": "https://www.ceskenoviny.cz/sluzby/rss/cr.php",
@@ -54,6 +55,7 @@
5455
{
5556
"has_images": True,
5657
"all_entries_have_images": False,
58+
"has_images_in_summary": True,
5759
"has_unique_links": False,
5860
"sensor_config": {
5961
"name": "buienradar_nl",
@@ -72,6 +74,7 @@
7274
},
7375
{
7476
"has_images": False,
77+
"has_unique_dates": False,
7578
"sensor_config": {
7679
"name": "api_met_no_metalerts",
7780
"feed_url": "https://api.met.no/weatherapi/metalerts/1.1/",
@@ -85,13 +88,34 @@
8588
"sensor_config": {
8689
"name": "anp_nieuws",
8790
"feed_url": "https://www.omnycontent.com/d/playlist/56ccbbb7-0ff7-4482-9d99-a88800f49f6c/a49c87f6-d567-4189-8692-a8e2009eaf86/9fea2041-fccd-4fcf-8cec-a8e2009eeca2/podcast.rss",
88-
"inclusions": ["title", "link", "published", "summary"],
91+
"inclusions": ["title", "link", "published", "summary", "image"],
92+
},
93+
},
94+
{
95+
"has_images": True,
96+
"all_entries_have_images": False,
97+
"has_images_in_summary": True,
98+
"all_entries_have_summary": False,
99+
"sensor_config": {
100+
"name": "alle_meldungen",
101+
"feed_url": "https://rss.sueddeutsche.de/alles/",
102+
"inclusions": ["image", "title", "link", "published", "summary"],
103+
"remove_summary_image": True,
104+
},
105+
},
106+
{
107+
"has_images": True,
108+
"has_unique_dates": False,
109+
"sensor_config": {
110+
"name": "stern_auto",
111+
"feed_url": "https://www.stern.de/feed/standard/auto/",
112+
"inclusions": ["image", "title", "link", "published", "summary"],
89113
},
90114
},
91115
]
92116

93117
DEFAULT_EXCLUSIONS: list[str] = []
94-
DEFAULT_INCLUSIONS = ["image", "title", "link", "published"]
118+
DEFAULT_INCLUSIONS = ["image", "title", "link", "summary", "published"]
95119
DATE_FORMAT = "%a, %d %b %Y %H:%M:%S UTC%z"
96120

97121
URLS_HEADERS_REQUIRED = [

tests/data/alle_meldungen.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"has_images": true,
3+
"all_entries_have_images": false,
4+
"has_images_in_summary": true,
5+
"all_entries_have_summary": false,
6+
"sensor_config": {
7+
"name": "alle_meldungen",
8+
"feed_url": "https://rss.sueddeutsche.de/alles/",
9+
"inclusions": [
10+
"image",
11+
"title",
12+
"link",
13+
"published",
14+
"summary"
15+
],
16+
"remove_summary_image": true
17+
},
18+
"download_date": "2024-02-23T21:08:09.183484+00:00"
19+
}

tests/data/alle_meldungen.xml

Lines changed: 231 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/stern_auto.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"has_images": true,
3+
"has_unique_dates": false,
4+
"sensor_config": {
5+
"name": "stern_auto",
6+
"feed_url": "https://www.stern.de/feed/standard/auto/",
7+
"inclusions": [
8+
"image",
9+
"title",
10+
"link",
11+
"published",
12+
"summary"
13+
]
14+
},
15+
"download_date": "2024-02-23T21:08:09.183484+00:00"
16+
}

0 commit comments

Comments
 (0)