Skip to content

Commit 6b5616d

Browse files
authored
Speedup tests (#1656)
1 parent 11abc5f commit 6b5616d

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

telescope/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def __aexit__(self, *args):
223223
retry_decorator = backoff.on_exception(
224224
backoff.expo,
225225
(aiohttp.ClientError, asyncio.TimeoutError),
226-
max_tries=config.REQUESTS_MAX_RETRIES + 1, # + 1 because REtries.
226+
max_tries=lambda: config.REQUESTS_MAX_RETRIES + 1, # + 1 because REtries.
227227
)
228228

229229

tests/checks/core/test_heartbeat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async def test_negative(mock_aioresponses):
2121
assert data == {}
2222

2323

24-
async def test_unreachable(mock_aioresponses):
24+
async def test_unreachable(mock_aioresponses, config):
25+
config.REQUESTS_MAX_RETRIES = 0
2526
status, data = await run("http://not-mocked")
2627

2728
assert status is False

tests/checks/core/test_readthedocs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ async def test_negative_not_recent_and_not_matching(mock_aioresponses):
209209

210210

211211
@pytest.mark.asyncio
212-
async def test_bad_content_type(mock_aioresponses):
212+
async def test_bad_content_type(mock_aioresponses, config):
213+
config.REQUESTS_MAX_RETRIES = 0
213214
mock_aioresponses.get(
214215
"https://readthedocs.org/api/v3/projects/remote-settings/versions/",
215216
body="<html>Not JSON</html>",
216217
content_type="text/html",
217218
status=403,
218-
repeat=True,
219219
)
220220

221221
with pytest.raises(aiohttp.client_exceptions.ContentTypeError) as excinfo:

tests/test_basic_endpoints.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ async def test_heartbeat(cli, config, mock_aioresponses):
4747
assert response.status == 200
4848

4949

50-
async def test_heartbeat_cache(cli, config):
50+
async def test_heartbeat_cache(cli, config, mock_aioresponses):
51+
config.BUGTRACKER_URL = "http://bugzilla.local"
52+
mock_aioresponses.get(
53+
config.BUGTRACKER_URL + "/rest/whoami", payload={"name": "foo"}, repeat=True
54+
)
55+
5156
response = await cli.get("/__heartbeat__")
5257
body = await response.json()
5358
assert body["cache"] == "ok"
@@ -300,7 +305,10 @@ def __call__(self, url, **kwargs):
300305

301306
async def test_check_force_refresh(cli, mock_aioresponses):
302307
mock_aioresponses.get(
303-
"http://server.local/__heartbeat__", status=200, payload={"ok": True}
308+
"http://server.local/__heartbeat__",
309+
status=200,
310+
payload={"ok": True},
311+
repeat=True,
304312
)
305313

306314
resp = await cli.get("/checks/testproject/hb")

0 commit comments

Comments
 (0)