diff options
| author | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:53 -0800 |
|---|---|---|
| committer | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:53 -0800 |
| commit | 6b8067e668b6a37a19e07d84e9a0d2d2a99b4d31 (patch) | |
| tree | 6f3accf36834c541caa68b46c402d67febeed041 | |
| parent | c0aa0e1c9f7d7914e3062fe6503da870508b27cf (diff) | |
| download | gitlab-6b8067e668b6a37a19e07d84e9a0d2d2a99b4d31.tar.gz | |
chore: use constants from gitlab.const module
Have code use constants from the gitlab.const module instead of from
the top-level gitlab module.
| -rw-r--r-- | gitlab/mixins.py | 2 | ||||
| -rw-r--r-- | tests/functional/api/test_gitlab.py | 4 | ||||
| -rw-r--r-- | tests/functional/api/test_snippets.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_config.py | 5 | ||||
| -rw-r--r-- | tests/unit/test_gitlab.py | 12 |
5 files changed, 13 insertions, 12 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 0159ecd..916da3c 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -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. diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py index e79492f..d54a7f1 100644 --- a/tests/functional/api/test_gitlab.py +++ b/tests/functional/api/test_gitlab.py @@ -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): diff --git a/tests/functional/api/test_snippets.py b/tests/functional/api/test_snippets.py index 9e0f833..ce235f3 100644 --- a/tests/functional/api/test_snippets.py +++ b/tests/functional/api/test_snippets.py @@ -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, } ) diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 82b9714..2bc2d25 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -22,7 +22,8 @@ from unittest import mock import pytest -from gitlab import config, USER_AGENT +import gitlab +from gitlab import config custom_user_agent = "my-package/1.0.0" @@ -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), ], ) diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py index 688da07..0d486e9 100644 --- a/tests/unit/test_gitlab.py +++ b/tests/unit/test_gitlab.py @@ -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), @@ -185,7 +185,7 @@ def test_gitlab_subclass_from_config(default_config): @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"), ], ) |
