Mercurial > silorider
changeset 59:b404445082f8
Prevent unit tests from downloading fake posts
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 Oct 2023 11:54:24 -0700 |
parents | d65f6dced79f |
children | b7da3d97ea99 |
files | silorider/format.py tests/conftest.py tests/mockutil.py |
diffstat | 3 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/silorider/format.py Sat Oct 28 11:52:25 2023 -0700 +++ b/silorider/format.py Sat Oct 28 11:54:24 2023 -0700 @@ -9,6 +9,7 @@ logger = logging.getLogger(__name__) +_disable_get_card_info = False def format_entry(entry, *, limit=None, card_props=None, add_url='auto', url_flattener=None, url_mode=None): @@ -24,7 +25,7 @@ card = None # See if we can use a nice blurb for articles instead of their title. - if card_props and not entry.is_micropost: + if card_props and not entry.is_micropost and not _disable_get_card_info: card = get_card_info(entry, card_props, ctx) # Otherwise, find the best text, generally the title of the article, or the
--- a/tests/conftest.py Sat Oct 28 11:52:25 2023 -0700 +++ b/tests/conftest.py Sat Oct 28 11:54:24 2023 -0700 @@ -5,7 +5,9 @@ import logging import tempfile import pytest +import unittest.mock import silorider.main +import silorider.format logger = logging.getLogger(__name__) @@ -18,6 +20,8 @@ re_feed_test_sep = re.compile(r'^---$') +silorider.format._disable_get_card_info = True + class FeedFile(pytest.File): def collect(self): @@ -156,7 +160,7 @@ class FeedUtil: def makeFeed(self, *entries): - feed = '<html><body>\n' + feed = '<html><body class="h-feed">\n' for e in entries: feed += '<article class="h-entry">\n' feed += e