comparison tests/conftest.py @ 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 d3c4c5082bbc
children
comparison
equal deleted inserted replaced
58:d65f6dced79f 59:b404445082f8
3 import os.path 3 import os.path
4 import re 4 import re
5 import logging 5 import logging
6 import tempfile 6 import tempfile
7 import pytest 7 import pytest
8 import unittest.mock
8 import silorider.main 9 import silorider.main
10 import silorider.format
9 11
10 12
11 logger = logging.getLogger(__name__) 13 logger = logging.getLogger(__name__)
12 14
13 15
15 # if path.ext == ".html" and path.basename.startswith("feeds"): 17 # if path.ext == ".html" and path.basename.startswith("feeds"):
16 # return FeedFile(path, parent) 18 # return FeedFile(path, parent)
17 19
18 20
19 re_feed_test_sep = re.compile(r'^---$') 21 re_feed_test_sep = re.compile(r'^---$')
22
23 silorider.format._disable_get_card_info = True
20 24
21 25
22 class FeedFile(pytest.File): 26 class FeedFile(pytest.File):
23 def collect(self): 27 def collect(self):
24 with self.fspath.open() as fp: 28 with self.fspath.open() as fp:
154 return FeedUtil() 158 return FeedUtil()
155 159
156 160
157 class FeedUtil: 161 class FeedUtil:
158 def makeFeed(self, *entries): 162 def makeFeed(self, *entries):
159 feed = '<html><body>\n' 163 feed = '<html><body class="h-feed">\n'
160 for e in entries: 164 for e in entries:
161 feed += '<article class="h-entry">\n' 165 feed += '<article class="h-entry">\n'
162 feed += e 166 feed += e
163 feed += '</article>\n' 167 feed += '</article>\n'
164 feed += '</body></html>' 168 feed += '</body></html>'