Skip to content
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

Improve test for sync_repo #6504

Merged
merged 4 commits into from
Jan 22, 2020
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
17 changes: 13 additions & 4 deletions readthedocs/rtd_tests/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,20 @@ def test_clean_build_after_failure_in_update_docs(self, run_setup, clean_build):
)
clean_build.assert_called_with(version.pk)

def test_sync_repository(self):
@patch('readthedocs.projects.tasks.api_v2')
@patch('readthedocs.projects.tasks.SyncRepositoryMixin.get_version')
@patch('readthedocs.projects.models.Project.checkout_path')
def test_sync_repository(self, checkout_path, get_version, api_v2):
# Create dir where to clone the repo
local_repo = os.path.join(mkdtemp(), 'local')
os.mkdir(local_repo)
checkout_path.return_value = local_repo

version = self.project.versions.get(slug=LATEST)
with mock_api(self.repo):
result = tasks.sync_repository_task.delay(version.pk)
self.assertTrue(result.successful())
get_version.return_value = version

result = tasks.sync_repository_task(version.pk)
self.assertTrue(result)

@patch('readthedocs.projects.tasks.clean_build')
def test_clean_build_after_sync_repository(self, clean_build):
Expand Down