def test_sync_skip_personal(): project_list = generate_project_list(pid=1, is_personal=True) with patch( "gitlab.v4.objects.ProjectManager.list", return_value=project_list["gitlab"] ), patch( "github.AuthenticatedUser.AuthenticatedUser.get_repos", return_value=project_list["github"], ), patch( "zoo.repos.tasks.settings.SYNC_REPOS_SKIP_PERSONAL", True ): sync_repos() gitlab_project = project_list["gitlab"][0] github_project = project_list["github"][0] with pytest.raises(Repository.DoesNotExist): Repository.objects.get( remote_id=gitlab_project.id, provider=Provider.GITLAB.value ) with pytest.raises(Repository.DoesNotExist): Repository.objects.get( remote_id=github_project.id, provider=Provider.GITHUB.value )
def test_sync_moved_repo(repository): project_list = generate_project_list(repository.remote_id) with patch( "gitlab.v4.objects.ProjectManager.list", return_value=project_list["gitlab"] ), patch( "github.AuthenticatedUser.AuthenticatedUser.get_repos", return_value=project_list["github"], ): sync_repos() gitlab_project = project_list["gitlab"][0] repository = Repository.objects.get( remote_id=gitlab_project.id, provider=Provider.GITLAB.value ) assert gitlab_project.namespace["full_path"] == repository.owner assert gitlab_project.path == repository.name assert gitlab_project.web_url == repository.url github_project = project_list["github"][0] repository = Repository.objects.get( remote_id=github_project.id, provider=Provider.GITHUB.value ) assert github_project.owner.login == repository.owner assert github_project.name == repository.name assert github_project.svn_url == repository.url
def test_sync_untouched_repo(repository): project_list = generate_project_list(repository.remote_id, repository.owner, repository.name, repository.url) with patch("gitlab.v4.objects.ProjectManager.list", return_value=project_list["gitlab"]), patch( "github.AuthenticatedUser.AuthenticatedUser.get_repos", return_value=project_list["github"], ): sync_repos() gitlab_project = project_list["gitlab"][0] assert gitlab_project.id == repository.remote_id assert gitlab_project.namespace["full_path"] == repository.owner assert gitlab_project.path == repository.name assert gitlab_project.web_url == repository.url github_project = project_list["github"][0] assert github_project.id == repository.remote_id + 1 assert github_project.owner.login == repository.owner assert github_project.name == repository.name assert github_project.svn_url == repository.url