Skip to content

Commit cfd83b6

Browse files
authored
bot: Do not wait in Taskcluster unit tests, fixes #449 (#470)
1 parent a2e21d8 commit cfd83b6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

bot/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import hglib
1414
import pytest
1515
import responses
16+
import tenacity
1617

1718
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures")
1819

@@ -405,3 +406,11 @@ def _sum(name):
405406
"linesMissed": _sum("linesMissed"),
406407
"linesTotal": _sum("linesTotal"),
407408
}
409+
410+
411+
@pytest.fixture
412+
def mock_tenacity(monkeypatch):
413+
"""
414+
Mock Tenacity wait function to avoid spening time in unit tests
415+
"""
416+
monkeypatch.setattr(tenacity, "wait_fixed", lambda x: None)

bot/tests/test_taskcluster.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
from unittest import mock
65
from zipfile import BadZipFile
76

87
import pytest
@@ -256,8 +255,7 @@ def test_get_platform(task_name, expected):
256255
assert taskcluster.get_platform(task) == expected
257256

258257

259-
@mock.patch("time.sleep")
260-
def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
258+
def test_download_artifact_forbidden(mock_taskcluster, tmpdir, mock_tenacity):
261259
responses.add(
262260
responses.GET,
263261
"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip",
@@ -278,8 +276,7 @@ def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
278276
assert len(responses.calls) == 5
279277

280278

281-
@mock.patch("time.sleep")
282-
def test_download_artifact_badzip(mocked_sleep, mock_taskcluster, tmpdir):
279+
def test_download_artifact_badzip(mock_taskcluster, tmpdir, mock_tenacity):
283280
responses.add(
284281
responses.GET,
285282
"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip",

0 commit comments

Comments
 (0)