Skip to content

Add test case for send_notifications on VersionLockedError #4958

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 3 commits into from
Jan 10, 2019
Merged
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
20 changes: 20 additions & 0 deletions readthedocs/rtd_tests/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from readthedocs.rtd_tests.utils import make_test_git
from readthedocs.rtd_tests.base import RTDTestCase
from readthedocs.rtd_tests.mocks.mock_api import mock_api
from readthedocs.doc_builder.exceptions import VersionLockedError


class TestCeleryBuilding(RTDTestCase):
Expand Down Expand Up @@ -117,6 +118,25 @@ def test_update_docs_unexpected_build_exception(self, mock_build_docs):
intersphinx=False)
self.assertTrue(result.successful())

@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.setup_python_environment', new=MagicMock)
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.build_docs', new=MagicMock)
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.send_notifications')
@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()

build = get(Build, project=self.project,
version=self.project.versions.first())
with mock_api(self.repo) as mapi:
result = tasks.update_docs_task.delay(
self.project.pk,
build_pk=build.pk,
record=False,
intersphinx=False)

mock_send_notifications.assert_not_called()
self.assertTrue(result.successful())

def test_sync_repository(self):
version = self.project.versions.get(slug=LATEST)
with mock_api(self.repo):
Expand Down