← 返回首页
test: increase client coverage · python-gitlab/python-gitlab@00aec96 · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Commit 00aec96

Browse files
authored andcommitted
test: increase client coverage
1 parent 3d000d3 commit 00aec96

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎tests/functional/api/test_gitlab.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def test_markdown(gl):
3535
assert "foo" in html
3636

3737

38+
def test_markdown_in_project(gl, project):
39+
html = gl.markdown("foo", project=project.path_with_namespace)
40+
assert "foo" in html
41+
42+
3843
def test_lint(gl):
3944
success, errors = gl.lint("Invalid")
4045
assert success is False
@@ -127,6 +132,11 @@ def test_notification_settings(gl):
127132
assert settings.level == gitlab.const.NOTIFICATION_LEVEL_WATCH
128133

129134

135+
def test_search(gl):
136+
result = gl.search(scope=gitlab.const.SEARCH_SCOPE_USERS, search="Administrator")
137+
assert result[0]["id"] == 1
138+
139+
130140
def test_user_activities(gl):
131141
activities = gl.user_activities.list(query_parameters={"from": "2019-01-01"})
132142
assert isinstance(activities, list)
@@ -237,3 +247,8 @@ def test_list_as_list_false_warnings(gl):
237247
for warning in caught_warnings:
238248
assert isinstance(warning.message, DeprecationWarning)
239249
assert len(list(items)) > 20
250+
251+
252+
def test_list_with_as_list_and_iterator_raises(gl):
253+
with pytest.raises(ValueError, match="`as_list` or `iterator`"):
254+
gl.gitlabciymls.list(as_list=False, iterator=True)

‎tests/unit/test_gitlab.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import copy
20+
import logging
2021
import pickle
2122
import warnings
23+
from http.client import HTTPConnection
2224

2325
import pytest
2426
import responses
@@ -100,6 +102,14 @@ def test_gitlab_as_context_manager():
100102
assert isinstance(gl, gitlab.Gitlab)
101103

102104

105+
def test_gitlab_enable_debug(gl):
106+
gl.enable_debug()
107+
108+
logger = logging.getLogger("requests.packages.urllib3")
109+
assert logger.level == logging.DEBUG
110+
assert HTTPConnection.debuglevel == 1
111+
112+
103113
@responses.activate
104114
@pytest.mark.parametrize(
105115
"status_code,response_json,expected",
@@ -143,6 +153,20 @@ def test_gitlab_get_license(gl, response_json, expected):
143153
assert gitlab_license == expected
144154

145155

156+
@responses.activate
157+
def test_gitlab_set_license(gl):
158+
responses.add(
159+
method=responses.POST,
160+
url="http://localhost/api/v4/license",
161+
json={"id": 1, "plan": "premium"},
162+
status=201,
163+
match=helpers.MATCH_EMPTY_QUERY_PARAMS,
164+
)
165+
166+
gitlab_license = gl.set_license("yJkYXRhIjoiMHM5Q")
167+
assert gitlab_license["plan"] == "premium"
168+
169+
146170
@responses.activate
147171
def test_gitlab_build_list(gl, resp_page_1, resp_page_2):
148172
responses.add(**resp_page_1)

0 commit comments

Comments
 (0)

Footer

© 2026 GitHub, Inc.