# HG changeset patch # User Ludovic Chabant # Date 1698519264 25200 # Node ID b404445082f8d64aac58000d25724d2f0801af5a # Parent d65f6dced79f93ae9eed449ecff597b6e638174b Prevent unit tests from downloading fake posts diff -r d65f6dced79f -r b404445082f8 silorider/format.py --- 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 diff -r d65f6dced79f -r b404445082f8 tests/conftest.py --- 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 = '\n' + feed = '\n' for e in entries: feed += '
\n' feed += e diff -r d65f6dced79f -r b404445082f8 tests/mockutil.py --- a/tests/mockutil.py Sat Oct 28 11:52:25 2023 -0700 +++ b/tests/mockutil.py Sat Oct 28 11:54:24 2023 -0700 @@ -6,7 +6,7 @@ return m -def _patched_urlretrieve(url): +def _patched_urlretrieve(url, filename=None): return ('/retrieved/' + url.lstrip('/'), None)