Skip to content
Snippets Groups Projects
Verified Commit d113017c authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Suppress python-gitlab UserWarning

parent 37d3a9da
No related branches found
No related tags found
1 merge request!2121Suppress python-gitlab UserWarning
......@@ -134,13 +134,13 @@ class GitLabProvider(GitProvider):
gl = self._get_gitlab_client(self.credentials)
# Creating a webhook on a repo requires Maintainer (40) or Owner (50) access levels
# See https://docs.gitlab.com/ce/api/members.html#valid-access-levels
return gl.projects.list(min_access_level=40, search=query)
return gl.projects.list(min_access_level=40, search=query, get_all=False)
def get_latest_commit_sha(self, repo):
project = self._get_project_from_repo(repo)
# Since ref_name isn't specified, we will use the repository default branch
# See : https://docs.gitlab.com/ee/api/commits.html#list-repository-commits
return project.commits.list()[0].id
return project.commits.list(per_page=1, get_all=False)[0].id
def to_dict(self, project):
return {
......@@ -298,10 +298,10 @@ class GitLabProvider(GitProvider):
except ValueError:
logger.warning(f'{ref_type.value} {ref.name} was ignored during revision creation')
for branch in project.branches.list():
for branch in project.branches.list(get_all=True):
_update_reference(branch, GitRefType.Branch)
for tag in project.tags.list():
for tag in project.tags.list(get_all=True):
_update_reference(tag, GitRefType.Tag)
def handle_webhook(self, repo, request):
......
......@@ -51,7 +51,7 @@ class TestGitLabProvider(FixtureTestCase):
self.assertEqual(self.gl_mock().projects.list.call_count, 1)
args, kwargs = self.gl_mock().projects.list.call_args
self.assertTupleEqual(args, ())
self.assertDictEqual(kwargs, {'min_access_level': 40, 'search': None})
self.assertDictEqual(kwargs, {'get_all': False, 'min_access_level': 40, 'search': None})
@responses.activate
@override_settings(PUBLIC_HOSTNAME='https://arkindex.localhost', GITLAB_APP_ID='abcd', GITLAB_APP_SECRET='s3kr3t')
......@@ -102,7 +102,7 @@ class TestGitLabProvider(FixtureTestCase):
self.assertEqual(self.gl_mock().projects.list.call_count, 1)
args, kwargs = self.gl_mock().projects.list.call_args
self.assertTupleEqual(args, ())
self.assertDictEqual(kwargs, {'min_access_level': 40, 'search': 'meh'})
self.assertDictEqual(kwargs, {'get_all': False, 'min_access_level': 40, 'search': 'meh'})
@override_settings(PUBLIC_HOSTNAME='https://arkindex.localhost')
def test_list_repos_requires_credentials(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment