diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-01-31 17:58:20 +0100 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-01-31 18:15:12 +0100 |
commit | c5a37e7e37a62372c250dfc8c0799e847eecbc30 (patch) | |
tree | 0c006b3e087a86b75d810cb2983d0c0acb6f0edd /gitlab/tests/test_gitlab.py | |
parent | 4bb201b92ef0dcc14a7a9c83e5600ba5b118fc33 (diff) | |
download | gitlab-c5a37e7e37a62372c250dfc8c0799e847eecbc30.tar.gz |
test(api,cli): add tests for custom user agent
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index 553afb3..4a82207 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -18,9 +18,10 @@ import pickle +import pytest from httmock import HTTMock, response, urlmatch, with_httmock # noqa -from gitlab import Gitlab, GitlabList +from gitlab import Gitlab, GitlabList, USER_AGENT from gitlab.v4.objects import CurrentUser @@ -139,3 +140,15 @@ def test_gitlab_subclass_from_config(default_config): config_path = default_config gl = MyGitlab.from_config("one", [config_path]) assert isinstance(gl, MyGitlab) + + +@pytest.mark.parametrize( + "kwargs,expected_agent", + [ + ({}, USER_AGENT), + ({"user_agent": "my-package/1.0.0"}, "my-package/1.0.0"), + ], +) +def test_gitlab_user_agent(kwargs, expected_agent): + gl = Gitlab("http://localhost", **kwargs) + assert gl.headers["User-Agent"] == expected_agent |