From 750fd9352ddee563faf0416c92fb5e972f8e1d64 Mon Sep 17 00:00:00 2001 From: lemon24 Date: Thu, 2 Jan 2025 23:12:55 +0200 Subject: [PATCH] Add Entry.feed_resolved_title test. --- tests/test_types.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_types.py b/tests/test_types.py index e290542e..395b8e21 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -9,6 +9,7 @@ from reader import Entry from reader import EntryError from reader import EntrySearchResult +from reader import EntrySource from reader import ExceptionInfo from reader import Feed from reader import FeedError @@ -259,6 +260,33 @@ def test_entry_updated_not_none(): assert entry.updated_not_none == entry.updated +def entry_with_feed_title(feed=None, user=None, source=None): + return Entry( + 'entry', + feed=Feed('feed', title=feed, user_title=user), + source=EntrySource(title=source) if source else None, + ) + + +@pytest.mark.parametrize( + 'entry, title', + [ + (entry_with_feed_title(), None), + (entry_with_feed_title(feed='feed'), 'feed'), + (entry_with_feed_title(user='user'), 'user'), + (entry_with_feed_title(source='source'), 'source'), + (entry_with_feed_title(feed='feed', user='user'), 'user'), + (entry_with_feed_title(feed='feed', source='source'), 'source (feed)'), + ( + entry_with_feed_title(feed='feed', user='user', source='source'), + 'source (user)', + ), + ], +) +def test_entry_feed_resolved_title(entry, title): + assert entry.feed_resolved_title == title + + @pytest.mark.parametrize( 'entry_kwargs, kwargs, expected', [