Skip to content

Commit 18c22e5

Browse files
chore: use constants from gitlab.const module
Have code use constants from the gitlab.const module instead of from the top-level gitlab module.
1 parent cf92904 commit 18c22e5

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

gitlab/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class AccessRequestMixin(_RestObjectBase):
618618
)
619619
@exc.on_http_error(exc.GitlabUpdateError)
620620
def approve(
621-
self, access_level: int = gitlab.DEVELOPER_ACCESS, **kwargs: Any
621+
self, access_level: int = gitlab.const.DEVELOPER_ACCESS, **kwargs: Any
622622
) -> None:
623623
"""Approve an access request.
624624

tests/functional/api/test_gitlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def test_namespaces(gl):
118118

119119
def test_notification_settings(gl):
120120
settings = gl.notificationsettings.get()
121-
settings.level = gitlab.NOTIFICATION_LEVEL_WATCH
121+
settings.level = gitlab.const.NOTIFICATION_LEVEL_WATCH
122122
settings.save()
123123

124124
settings = gl.notificationsettings.get()
125-
assert settings.level == gitlab.NOTIFICATION_LEVEL_WATCH
125+
assert settings.level == gitlab.const.NOTIFICATION_LEVEL_WATCH
126126

127127

128128
def test_user_activities(gl):

tests/functional/api/test_snippets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_project_snippets(project):
3333
"title": "snip1",
3434
"file_name": "foo.py",
3535
"content": "initial content",
36-
"visibility": gitlab.VISIBILITY_PRIVATE,
36+
"visibility": gitlab.const.VISIBILITY_PRIVATE,
3737
}
3838
)
3939

tests/unit/test_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import mock
2323
import pytest
2424

25-
from gitlab import config, USER_AGENT
25+
import gitlab
26+
from gitlab import config
2627

2728
custom_user_agent = "my-package/1.0.0"
2829

@@ -252,7 +253,7 @@ def test_data_from_helper(m_open, path_exists, tmp_path):
252253
@pytest.mark.parametrize(
253254
"config_string,expected_agent",
254255
[
255-
(valid_config, USER_AGENT),
256+
(valid_config, gitlab.const.USER_AGENT),
256257
(custom_user_agent_config, custom_user_agent),
257258
],
258259
)

tests/unit/test_gitlab.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import pytest
2222
from httmock import HTTMock, response, urlmatch, with_httmock # noqa
2323

24-
from gitlab import DEFAULT_URL, Gitlab, GitlabList, USER_AGENT
24+
import gitlab
25+
from gitlab import Gitlab, GitlabList
2526
from gitlab.v4.objects import CurrentUser
2627

2728
localhost = "http://localhost"
@@ -129,19 +130,19 @@ def test_gitlab_token_auth(gl, callback=None):
129130

130131
def test_gitlab_default_url():
131132
gl = Gitlab()
132-
assert gl.url == DEFAULT_URL
133+
assert gl.url == gitlab.const.DEFAULT_URL
133134

134135

135136
@pytest.mark.parametrize(
136137
"args, kwargs, expected_url, expected_private_token, expected_oauth_token",
137138
[
138-
([], {}, DEFAULT_URL, None, None),
139-
([None, token], {}, DEFAULT_URL, token, None),
139+
([], {}, gitlab.const.DEFAULT_URL, None, None),
140+
([None, token], {}, gitlab.const.DEFAULT_URL, token, None),
140141
([localhost], {}, localhost, None, None),
141142
([localhost, token], {}, localhost, token, None),
142143
([localhost, None, token], {}, localhost, None, token),
143-
([], {"private_token": token}, DEFAULT_URL, token, None),
144-
([], {"oauth_token": token}, DEFAULT_URL, None, token),
144+
([], {"private_token": token}, gitlab.const.DEFAULT_URL, token, None),
145+
([], {"oauth_token": token}, gitlab.const.DEFAULT_URL, None, token),
145146
([], {"url": localhost}, localhost, None, None),
146147
([], {"url": localhost, "private_token": token}, localhost, token, None),
147148
([], {"url": localhost, "oauth_token": token}, localhost, None, token),
@@ -185,7 +186,7 @@ class MyGitlab(Gitlab):
185186
@pytest.mark.parametrize(
186187
"kwargs,expected_agent",
187188
[
188-
({}, USER_AGENT),
189+
({}, gitlab.const.USER_AGENT),
189190
({"user_agent": "my-package/1.0.0"}, "my-package/1.0.0"),
190191
],
191192
)

0 commit comments

Comments
 (0)