Skip to content

Do not wait in Taskcluster unit tests #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bot/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import hglib
import pytest
import responses
import tenacity

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

Expand Down Expand Up @@ -405,3 +406,11 @@ def _sum(name):
"linesMissed": _sum("linesMissed"),
"linesTotal": _sum("linesTotal"),
}


@pytest.fixture
def mock_tenacity(monkeypatch):
"""
Mock Tenacity wait function to avoid spening time in unit tests
"""
monkeypatch.setattr(tenacity, "wait_fixed", lambda x: None)
7 changes: 2 additions & 5 deletions bot/tests/test_taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
import os
from unittest import mock
from zipfile import BadZipFile

import pytest
Expand Down Expand Up @@ -256,8 +255,7 @@ def test_get_platform(task_name, expected):
assert taskcluster.get_platform(task) == expected


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


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