summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-06-01 23:29:58 +0200
committerJohn Villalovos <john@sodarock.com>2022-06-02 07:21:28 -0700
commit00aec96ed0b60720362c6642b416567ff39aef09 (patch)
treeef2acac54dc968fc27cdca2c8c81d456fb5a8494
parent3d000d3de86306faee063f4edf9f09aff7590791 (diff)
downloadgitlab-00aec96ed0b60720362c6642b416567ff39aef09.tar.gz
test: increase client coverage
-rw-r--r--tests/functional/api/test_gitlab.py15
-rw-r--r--tests/unit/test_gitlab.py24
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py
index c9a24a0..3b3987e 100644
--- a/tests/functional/api/test_gitlab.py
+++ b/tests/functional/api/test_gitlab.py
@@ -35,6 +35,11 @@ def test_markdown(gl):
assert "foo" in html
+def test_markdown_in_project(gl, project):
+ html = gl.markdown("foo", project=project.path_with_namespace)
+ assert "foo" in html
+
+
def test_lint(gl):
success, errors = gl.lint("Invalid")
assert success is False
@@ -127,6 +132,11 @@ def test_notification_settings(gl):
assert settings.level == gitlab.const.NOTIFICATION_LEVEL_WATCH
+def test_search(gl):
+ result = gl.search(scope=gitlab.const.SEARCH_SCOPE_USERS, search="Administrator")
+ assert result[0]["id"] == 1
+
+
def test_user_activities(gl):
activities = gl.user_activities.list(query_parameters={"from": "2019-01-01"})
assert isinstance(activities, list)
@@ -237,3 +247,8 @@ def test_list_as_list_false_warnings(gl):
for warning in caught_warnings:
assert isinstance(warning.message, DeprecationWarning)
assert len(list(items)) > 20
+
+
+def test_list_with_as_list_and_iterator_raises(gl):
+ with pytest.raises(ValueError, match="`as_list` or `iterator`"):
+ gl.gitlabciymls.list(as_list=False, iterator=True)
diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py
index 13fc2d8..7e8ac21 100644
--- a/tests/unit/test_gitlab.py
+++ b/tests/unit/test_gitlab.py
@@ -17,8 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import copy
+import logging
import pickle
import warnings
+from http.client import HTTPConnection
import pytest
import responses
@@ -100,6 +102,14 @@ def test_gitlab_as_context_manager():
assert isinstance(gl, gitlab.Gitlab)
+def test_gitlab_enable_debug(gl):
+ gl.enable_debug()
+
+ logger = logging.getLogger("requests.packages.urllib3")
+ assert logger.level == logging.DEBUG
+ assert HTTPConnection.debuglevel == 1
+
+
@responses.activate
@pytest.mark.parametrize(
"status_code,response_json,expected",
@@ -144,6 +154,20 @@ def test_gitlab_get_license(gl, response_json, expected):
@responses.activate
+def test_gitlab_set_license(gl):
+ responses.add(
+ method=responses.POST,
+ url="http://localhost/api/v4/license",
+ json={"id": 1, "plan": "premium"},
+ status=201,
+ match=helpers.MATCH_EMPTY_QUERY_PARAMS,
+ )
+
+ gitlab_license = gl.set_license("yJkYXRhIjoiMHM5Q")
+ assert gitlab_license["plan"] == "premium"
+
+
+@responses.activate
def test_gitlab_build_list(gl, resp_page_1, resp_page_2):
responses.add(**resp_page_1)
obj = gl.http_list("/tests", iterator=True)