Skip to content

Commit

Permalink
chore: use constants from gitlab.const module
Browse files Browse the repository at this point in the history
Have code use constants from the gitlab.const module instead of from
the top-level gitlab module.
  • Loading branch information
JohnVillalovos committed Nov 30, 2021
1 parent c0aa0e1 commit 6b8067e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gitlab/mixins.py
Expand Up @@ -618,7 +618,7 @@ class AccessRequestMixin(_RestObjectBase):
)
@exc.on_http_error(exc.GitlabUpdateError)
def approve(
self, access_level: int = gitlab.DEVELOPER_ACCESS, **kwargs: Any
self, access_level: int = gitlab.const.DEVELOPER_ACCESS, **kwargs: Any
) -> None:
"""Approve an access request.
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/api/test_gitlab.py
Expand Up @@ -118,11 +118,11 @@ def test_namespaces(gl):

def test_notification_settings(gl):
settings = gl.notificationsettings.get()
settings.level = gitlab.NOTIFICATION_LEVEL_WATCH
settings.level = gitlab.const.NOTIFICATION_LEVEL_WATCH
settings.save()

settings = gl.notificationsettings.get()
assert settings.level == gitlab.NOTIFICATION_LEVEL_WATCH
assert settings.level == gitlab.const.NOTIFICATION_LEVEL_WATCH


def test_user_activities(gl):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/api/test_snippets.py
Expand Up @@ -33,7 +33,7 @@ def test_project_snippets(project):
"title": "snip1",
"file_name": "foo.py",
"content": "initial content",
"visibility": gitlab.VISIBILITY_PRIVATE,
"visibility": gitlab.const.VISIBILITY_PRIVATE,
}
)

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_config.py
Expand Up @@ -22,7 +22,8 @@

import pytest

from gitlab import config, USER_AGENT
import gitlab
from gitlab import config

custom_user_agent = "my-package/1.0.0"

Expand Down Expand Up @@ -252,7 +253,7 @@ def test_data_from_helper(m_open, path_exists, tmp_path):
@pytest.mark.parametrize(
"config_string,expected_agent",
[
(valid_config, USER_AGENT),
(valid_config, gitlab.const.USER_AGENT),
(custom_user_agent_config, custom_user_agent),
],
)
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_gitlab.py
Expand Up @@ -129,19 +129,19 @@ def test_gitlab_token_auth(gl, callback=None):

def test_gitlab_default_url():
gl = gitlab.Gitlab()
assert gl.url == gitlab.DEFAULT_URL
assert gl.url == gitlab.const.DEFAULT_URL


@pytest.mark.parametrize(
"args, kwargs, expected_url, expected_private_token, expected_oauth_token",
[
([], {}, gitlab.DEFAULT_URL, None, None),
([None, token], {}, gitlab.DEFAULT_URL, token, None),
([], {}, gitlab.const.DEFAULT_URL, None, None),
([None, token], {}, gitlab.const.DEFAULT_URL, token, None),
([localhost], {}, localhost, None, None),
([localhost, token], {}, localhost, token, None),
([localhost, None, token], {}, localhost, None, token),
([], {"private_token": token}, gitlab.DEFAULT_URL, token, None),
([], {"oauth_token": token}, gitlab.DEFAULT_URL, None, token),
([], {"private_token": token}, gitlab.const.DEFAULT_URL, token, None),
([], {"oauth_token": token}, gitlab.const.DEFAULT_URL, None, token),
([], {"url": localhost}, localhost, None, None),
([], {"url": localhost, "private_token": token}, localhost, token, None),
([], {"url": localhost, "oauth_token": token}, localhost, None, token),
Expand Down Expand Up @@ -185,7 +185,7 @@ class MyGitlab(gitlab.Gitlab):
@pytest.mark.parametrize(
"kwargs,expected_agent",
[
({}, gitlab.USER_AGENT),
({}, gitlab.const.USER_AGENT),
({"user_agent": "my-package/1.0.0"}, "my-package/1.0.0"),
],
)
Expand Down

0 comments on commit 6b8067e

Please sign in to comment.