Skip to content

Commit fbc048b

Browse files
committed
Fix tests that decided to start failing
1 parent 2ecda6a commit fbc048b

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

readthedocs/rtd_tests/mocks/mock_api.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ def __init__(self, repo):
7777
def project(self, x):
7878
return ProjectData()
7979

80+
def build(self, x):
81+
return mock.Mock(**{'get.return_value': {'state': 'triggered'}})
82+
83+
def command(self, x):
84+
return mock.Mock(**{'get.return_value': {}})
85+
8086

8187
@contextmanager
8288
def mock_api(repo):
8389
api_mock = MockApi(repo)
84-
with (
85-
mock.patch('readthedocs.restapi.client.api', api_mock) and
86-
mock.patch('readthedocs.api.client.api', api_mock) and
87-
mock.patch('readthedocs.projects.tasks.api_v2', api_mock) and
88-
mock.patch('readthedocs.projects.tasks.api_v1', api_mock)):
90+
with mock.patch('readthedocs.restapi.client.api', api_mock), \
91+
mock.patch('readthedocs.api.client.api', api_mock), \
92+
mock.patch('readthedocs.projects.tasks.api_v2', api_mock), \
93+
mock.patch('readthedocs.projects.tasks.api_v1', api_mock), \
94+
mock.patch('readthedocs.doc_builder.environments.api_v1', api_mock), \
95+
mock.patch('readthedocs.doc_builder.environments.api_v2', api_mock):
8996
yield api_mock

readthedocs/rtd_tests/tests/test_celery.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
from tempfile import mkdtemp
66

77
from django.contrib.auth.models import User
8+
from django_dynamic_fixture import get
89
from mock import patch, MagicMock
910

11+
from readthedocs.builds.models import Build
1012
from readthedocs.projects.models import Project
1113
from readthedocs.projects import tasks
1214

@@ -66,10 +68,14 @@ def test_clear_artifacts(self):
6668
@patch('readthedocs.projects.tasks.UpdateDocsTask.setup_vcs',
6769
new=MagicMock)
6870
def test_update_docs(self):
69-
with mock_api(self.repo):
70-
update_docs = tasks.UpdateDocsTask()
71-
result = update_docs.delay(self.project.pk, record=False,
72-
intersphinx=False)
71+
build = get(Build, project=self.project,
72+
version=self.project.versions.first())
73+
with mock_api(self.repo) as mapi:
74+
result = tasks.update_docs.delay(
75+
self.project.pk,
76+
build_pk=build.pk,
77+
record=False,
78+
intersphinx=False)
7379
self.assertTrue(result.successful())
7480

7581
def test_update_imported_doc(self):

0 commit comments

Comments
 (0)