Skip to content

Fix tests on master #5769

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
Jun 5, 2019
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
23 changes: 14 additions & 9 deletions readthedocs/rtd_tests/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ def test_clear_artifacts(self):
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.build_docs', new=MagicMock)
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs', new=MagicMock)
def test_update_docs(self):
version = self.project.versions.first()
build = get(
Build, project=self.project,
version=self.project.versions.first(),
version=version,
)
with mock_api(self.repo) as mapi:
result = tasks.update_docs_task.delay(
self.project.pk,
version.pk,
build_pk=build.pk,
record=False,
intersphinx=False,
Expand All @@ -99,13 +100,14 @@ def test_update_docs(self):
def test_update_docs_unexpected_setup_exception(self, mock_setup_vcs):
exc = Exception()
mock_setup_vcs.side_effect = exc
version = self.project.versions.first()
build = get(
Build, project=self.project,
version=self.project.versions.first(),
version=version,
)
with mock_api(self.repo) as mapi:
result = tasks.update_docs_task.delay(
self.project.pk,
version.pk,
build_pk=build.pk,
record=False,
intersphinx=False,
Expand All @@ -119,13 +121,14 @@ def test_update_docs_unexpected_setup_exception(self, mock_setup_vcs):
def test_update_docs_unexpected_build_exception(self, mock_build_docs):
exc = Exception()
mock_build_docs.side_effect = exc
version = self.project.versions.first()
build = get(
Build, project=self.project,
version=self.project.versions.first(),
version=version,
)
with mock_api(self.repo) as mapi:
result = tasks.update_docs_task.delay(
self.project.pk,
version.pk,
build_pk=build.pk,
record=False,
intersphinx=False,
Expand All @@ -138,14 +141,16 @@ def test_update_docs_unexpected_build_exception(self, mock_build_docs):
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_vcs')
def test_no_notification_on_version_locked_error(self, mock_setup_vcs, mock_send_notifications):
mock_setup_vcs.side_effect = VersionLockedError()

version = self.project.versions.first()

build = get(
Build, project=self.project,
version=self.project.versions.first(),
version=version,
)
with mock_api(self.repo) as mapi:
with mock_api(self.repo):
result = tasks.update_docs_task.delay(
self.project.pk,
version.pk,
build_pk=build.pk,
record=False,
intersphinx=False,
Expand Down
7 changes: 5 additions & 2 deletions readthedocs/vcs_support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ class NonBlockingLock:
"""

def __init__(self, project, version, max_lock_age=None):
self.base_path = project.doc_path
self.fpath = os.path.join(
project.doc_path,
'%s__rtdlock' % version.slug,
self.base_path,
f'{version.slug}__rtdlock',
)
self.max_lock_age = max_lock_age
self.name = project.slug
Expand All @@ -118,6 +119,8 @@ def __enter__(self):
)
elif path_exists:
raise LockTimeout('Lock ({}): Lock still active'.format(self.name),)
# Create dirs if they don't exists
os.makedirs(self.base_path, exist_ok=True)
open(self.fpath, 'w').close()
return self

Expand Down