Skip to content

Commit cf54414

Browse files
committed
Fix tests on master
Two PRs got merged and one modified the behaviour that the other one was depending on. This was giving an error in the lock creation because the base dir wasn't created yet. The rest of tests something I forgot to change project_pk -> version_pk (I did a grep, didn't find more)
1 parent c79dbe4 commit cf54414

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

readthedocs/rtd_tests/tests/test_celery.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ def test_clear_artifacts(self):
7979
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.build_docs', new=MagicMock)
8080
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs', new=MagicMock)
8181
def test_update_docs(self):
82+
version = self.project.versions.first()
8283
build = get(
8384
Build, project=self.project,
84-
version=self.project.versions.first(),
85+
version=version,
8586
)
8687
with mock_api(self.repo) as mapi:
8788
result = tasks.update_docs_task.delay(
88-
self.project.pk,
89+
version.pk,
8990
build_pk=build.pk,
9091
record=False,
9192
intersphinx=False,
@@ -99,13 +100,14 @@ def test_update_docs(self):
99100
def test_update_docs_unexpected_setup_exception(self, mock_setup_vcs):
100101
exc = Exception()
101102
mock_setup_vcs.side_effect = exc
103+
version = self.project.versions.first()
102104
build = get(
103105
Build, project=self.project,
104-
version=self.project.versions.first(),
106+
version=version,
105107
)
106108
with mock_api(self.repo) as mapi:
107109
result = tasks.update_docs_task.delay(
108-
self.project.pk,
110+
version.pk,
109111
build_pk=build.pk,
110112
record=False,
111113
intersphinx=False,
@@ -119,13 +121,14 @@ def test_update_docs_unexpected_setup_exception(self, mock_setup_vcs):
119121
def test_update_docs_unexpected_build_exception(self, mock_build_docs):
120122
exc = Exception()
121123
mock_build_docs.side_effect = exc
124+
version = self.project.versions.first()
122125
build = get(
123126
Build, project=self.project,
124-
version=self.project.versions.first(),
127+
version=version,
125128
)
126129
with mock_api(self.repo) as mapi:
127130
result = tasks.update_docs_task.delay(
128-
self.project.pk,
131+
version.pk,
129132
build_pk=build.pk,
130133
record=False,
131134
intersphinx=False,
@@ -138,14 +141,16 @@ def test_update_docs_unexpected_build_exception(self, mock_build_docs):
138141
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs')
139142
def test_no_notification_on_version_locked_error(self, mock_setup_vcs, mock_send_notifications):
140143
mock_setup_vcs.side_effect = VersionLockedError()
144+
145+
version = self.project.versions.first()
141146

142147
build = get(
143148
Build, project=self.project,
144-
version=self.project.versions.first(),
149+
version=version,
145150
)
146-
with mock_api(self.repo) as mapi:
151+
with mock_api(self.repo):
147152
result = tasks.update_docs_task.delay(
148-
self.project.pk,
153+
version.pk,
149154
build_pk=build.pk,
150155
record=False,
151156
intersphinx=False,

readthedocs/vcs_support/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ class NonBlockingLock:
9595
"""
9696

9797
def __init__(self, project, version, max_lock_age=None):
98+
self.base_path = project.doc_path
9899
self.fpath = os.path.join(
99-
project.doc_path,
100-
'%s__rtdlock' % version.slug,
100+
self.base_path,
101+
f'{version.slug}__rtdlock',
101102
)
102103
self.max_lock_age = max_lock_age
103104
self.name = project.slug
@@ -118,6 +119,8 @@ def __enter__(self):
118119
)
119120
elif path_exists:
120121
raise LockTimeout('Lock ({}): Lock still active'.format(self.name),)
122+
# Create dirs if they don't exists
123+
os.makedirs(self.base_path, exist_ok=True)
121124
open(self.fpath, 'w').close()
122125
return self
123126

0 commit comments

Comments
 (0)