summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-05-15 18:20:01 +0200
committerJohn Villalovos <john@sodarock.com>2022-07-21 15:03:11 -0700
commit7c71d5db1199164b3fa9958e3c3bc6ec96efc78d (patch)
tree1b17a6e3467e22187ef0530c9174534e816c3560 /tests
parent0549afa6631f21ab98e1f1457607daa03b398185 (diff)
downloadgitlab-7c71d5db1199164b3fa9958e3c3bc6ec96efc78d.tar.gz
fix: add `get_all` param (and `--get-all`) to allow passing `all` to API
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/api/test_gitlab.py14
-rw-r--r--tests/functional/api/test_repository.py20
-rw-r--r--tests/functional/api/test_snippets.py4
-rw-r--r--tests/functional/cli/test_cli_repository.py73
-rw-r--r--tests/functional/cli/test_cli_v4.py53
-rwxr-xr-xtests/functional/ee-test.py8
-rw-r--r--tests/unit/mixins/test_mixin_methods.py2
-rw-r--r--tests/unit/test_gitlab.py4
-rw-r--r--tests/unit/test_gitlab_http_methods.py4
9 files changed, 111 insertions, 71 deletions
diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py
index 3b6d925..6627e38 100644
--- a/tests/functional/api/test_gitlab.py
+++ b/tests/functional/api/test_gitlab.py
@@ -18,7 +18,7 @@ def test_broadcast_messages(gl):
msg.save()
msg_id = msg.id
- msg = gl.broadcastmessages.list(all=True)[0]
+ msg = gl.broadcastmessages.list(get_all=True)[0]
assert msg.color == "#444444"
msg = gl.broadcastmessages.get(msg_id)
@@ -86,13 +86,13 @@ def test_template_dockerfile(gl):
def test_template_gitignore(gl):
- assert gl.gitignores.list(all=True)
+ assert gl.gitignores.list(get_all=True)
gitignore = gl.gitignores.get("Node")
assert gitignore.content is not None
def test_template_gitlabciyml(gl):
- assert gl.gitlabciymls.list(all=True)
+ assert gl.gitlabciymls.list(get_all=True)
gitlabciyml = gl.gitlabciymls.get("Nodejs")
assert gitlabciyml.content is not None
@@ -114,10 +114,10 @@ def test_hooks(gl):
def test_namespaces(gl):
- namespace = gl.namespaces.list(all=True)
+ namespace = gl.namespaces.list(get_all=True)
assert namespace
- namespace = gl.namespaces.list(search="root", all=True)[0]
+ namespace = gl.namespaces.list(search="root", get_all=True)[0]
assert namespace.kind == "user"
@@ -217,8 +217,8 @@ def test_list_all_false_nowarning(gl, recwarn):
def test_list_all_true_nowarning(gl, recwarn):
- """Using `all=True` will disable the warning"""
- items = gl.gitlabciymls.list(all=True)
+ """Using `get_all=True` will disable the warning"""
+ items = gl.gitlabciymls.list(get_all=True)
assert not recwarn
assert len(items) > 20
diff --git a/tests/functional/api/test_repository.py b/tests/functional/api/test_repository.py
index bda046e..dc3d360 100644
--- a/tests/functional/api/test_repository.py
+++ b/tests/functional/api/test_repository.py
@@ -105,6 +105,26 @@ def test_create_commit(project):
assert isinstance(commit.merge_requests(), list)
+def test_list_all_commits(project):
+ data = {
+ "branch": "new-branch",
+ "start_branch": "main",
+ "commit_message": "New commit on new branch",
+ "actions": [
+ {"action": "create", "file_path": "new-file", "content": "new content"}
+ ],
+ }
+ commit = project.commits.create(data)
+
+ commits = project.commits.list(all=True)
+ assert commit not in commits
+
+ # Listing commits on other branches requires `all` parameter passed to the API
+ all_commits = project.commits.list(get_all=True, all=True)
+ assert commit in all_commits
+ assert len(all_commits) > len(commits)
+
+
def test_create_commit_status(project):
commit = project.commits.list()[0]
status = commit.statuses.create({"state": "success", "sha": commit.id})
diff --git a/tests/functional/api/test_snippets.py b/tests/functional/api/test_snippets.py
index f9084e1..a4808e7 100644
--- a/tests/functional/api/test_snippets.py
+++ b/tests/functional/api/test_snippets.py
@@ -2,7 +2,7 @@ import gitlab
def test_snippets(gl):
- snippets = gl.snippets.list(all=True)
+ snippets = gl.snippets.list(get_all=True)
assert not snippets
snippet = gl.snippets.create(
@@ -20,7 +20,7 @@ def test_snippets(gl):
assert snippet.user_agent_detail()["user_agent"]
snippet.delete()
- assert snippet not in gl.snippets.list(all=True)
+ assert snippet not in gl.snippets.list(get_all=True)
def test_project_snippets(project):
diff --git a/tests/functional/cli/test_cli_repository.py b/tests/functional/cli/test_cli_repository.py
new file mode 100644
index 0000000..7f521b4
--- /dev/null
+++ b/tests/functional/cli/test_cli_repository.py
@@ -0,0 +1,73 @@
+def test_project_create_file(gitlab_cli, project):
+ file_path = "README"
+ branch = "main"
+ content = "CONTENT"
+ commit_message = "Initial commit"
+
+ cmd = [
+ "project-file",
+ "create",
+ "--project-id",
+ project.id,
+ "--file-path",
+ file_path,
+ "--branch",
+ branch,
+ "--content",
+ content,
+ "--commit-message",
+ commit_message,
+ ]
+ ret = gitlab_cli(cmd)
+
+ assert ret.success
+
+
+def test_list_all_commits(gitlab_cli, project):
+ data = {
+ "branch": "new-branch",
+ "start_branch": "main",
+ "commit_message": "New commit on new branch",
+ "actions": [
+ {"action": "create", "file_path": "new-file", "content": "new content"}
+ ],
+ }
+ commit = project.commits.create(data)
+
+ cmd = ["project-commit", "list", "--project-id", project.id, "--get-all"]
+ ret = gitlab_cli(cmd)
+ assert commit.id not in ret.stdout
+
+ # Listing commits on other branches requires `all` parameter passed to the API
+ cmd = ["project-commit", "list", "--project-id", project.id, "--get-all", "--all"]
+ ret_all = gitlab_cli(cmd)
+ assert commit.id in ret_all.stdout
+ assert len(ret_all.stdout) > len(ret.stdout)
+
+
+def test_revert_commit(gitlab_cli, project):
+ commit = project.commits.list()[0]
+
+ cmd = [
+ "project-commit",
+ "revert",
+ "--project-id",
+ project.id,
+ "--id",
+ commit.id,
+ "--branch",
+ "main",
+ ]
+ ret = gitlab_cli(cmd)
+
+ assert ret.success
+
+
+def test_get_commit_signature_not_found(gitlab_cli, project):
+ commit = project.commits.list()[0]
+
+ cmd = ["project-commit", "signature", "--project-id", project.id, "--id", commit.id]
+ ret = gitlab_cli(cmd)
+
+ assert not ret.success
+ assert "404 Signature Not Found" in ret.stderr
diff --git a/tests/functional/cli/test_cli_v4.py b/tests/functional/cli/test_cli_v4.py
index 6b43730..62b893b 100644
--- a/tests/functional/cli/test_cli_v4.py
+++ b/tests/functional/cli/test_cli_v4.py
@@ -176,31 +176,6 @@ def test_list_user_memberships(gitlab_cli, user):
assert ret.success
-def test_project_create_file(gitlab_cli, project):
- file_path = "README"
- branch = "main"
- content = "CONTENT"
- commit_message = "Initial commit"
-
- cmd = [
- "project-file",
- "create",
- "--project-id",
- project.id,
- "--file-path",
- file_path,
- "--branch",
- branch,
- "--content",
- content,
- "--commit-message",
- commit_message,
- ]
- ret = gitlab_cli(cmd)
-
- assert ret.success
-
-
def test_create_project_issue(gitlab_cli, project):
title = "my issue"
description = "my issue description"
@@ -302,34 +277,6 @@ def test_accept_request_merge(gitlab_cli, project):
assert ret.success
-def test_revert_commit(gitlab_cli, project):
- commit = project.commits.list()[0]
-
- cmd = [
- "project-commit",
- "revert",
- "--project-id",
- project.id,
- "--id",
- commit.id,
- "--branch",
- "main",
- ]
- ret = gitlab_cli(cmd)
-
- assert ret.success
-
-
-def test_get_commit_signature_not_found(gitlab_cli, project):
- commit = project.commits.list()[0]
-
- cmd = ["project-commit", "signature", "--project-id", project.id, "--id", commit.id]
- ret = gitlab_cli(cmd)
-
- assert not ret.success
- assert "404 Signature Not Found" in ret.stderr
-
-
def test_create_project_label(gitlab_cli, project):
name = "prjlabel1"
description = "prjlabel1 description"
diff --git a/tests/functional/ee-test.py b/tests/functional/ee-test.py
index a356c80..2a539b0 100755
--- a/tests/functional/ee-test.py
+++ b/tests/functional/ee-test.py
@@ -53,20 +53,20 @@ mr.approvals.set_approvers(1, [1], [])
approval = mr.approvals.get()
assert approval.approvers[0]["user"]["id"] == 1
-ars = project1.approvalrules.list(all=True)
+ars = project1.approvalrules.list(get_all=True)
assert len(ars) == 0
project1.approvalrules.create(
{"name": "approval-rule", "approvals_required": 1, "group_ids": [group1.id]}
)
-ars = project1.approvalrules.list(all=True)
+ars = project1.approvalrules.list(get_all=True)
assert len(ars) == 1
assert ars[0].approvals_required == 2
ars[0].save()
-ars = project1.approvalrules.list(all=True)
+ars = project1.approvalrules.list(get_all=True)
assert len(ars) == 1
assert ars[0].approvals_required == 2
ars[0].delete()
-ars = project1.approvalrules.list(all=True)
+ars = project1.approvalrules.list(get_all=True)
assert len(ars) == 0
end_log()
diff --git a/tests/unit/mixins/test_mixin_methods.py b/tests/unit/mixins/test_mixin_methods.py
index 9121453..68b59a2 100644
--- a/tests/unit/mixins/test_mixin_methods.py
+++ b/tests/unit/mixins/test_mixin_methods.py
@@ -196,7 +196,7 @@ def test_list_mixin(gl):
assert obj.id in (42, 43)
# test list()
- obj_list = mgr.list(all=True)
+ obj_list = mgr.list(get_all=True)
assert isinstance(obj_list, list)
assert obj_list[0].id == 42
assert obj_list[1].id == 43
diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py
index eca4bea..4189174 100644
--- a/tests/unit/test_gitlab.py
+++ b/tests/unit/test_gitlab.py
@@ -215,10 +215,10 @@ def test_gitlab_build_list_missing_headers(gl, resp_page_1, resp_page_2):
@responses.activate
-def test_gitlab_all_omitted_when_iterator(gl, resp_page_1, resp_page_2):
+def test_gitlab_get_all_omitted_when_iterator(gl, resp_page_1, resp_page_2):
responses.add(**resp_page_1)
responses.add(**resp_page_2)
- result = gl.http_list("/tests", iterator=True, all=True)
+ result = gl.http_list("/tests", iterator=True, get_all=True)
assert isinstance(result, gitlab.GitlabList)
diff --git a/tests/unit/test_gitlab_http_methods.py b/tests/unit/test_gitlab_http_methods.py
index ace8e25..3d5a3fb 100644
--- a/tests/unit/test_gitlab_http_methods.py
+++ b/tests/unit/test_gitlab_http_methods.py
@@ -461,7 +461,7 @@ def test_list_request(gl):
assert isinstance(result, GitlabList)
assert len(list(result)) == 1
- result = gl.http_list("/projects", all=True)
+ result = gl.http_list("/projects", get_all=True)
assert isinstance(result, list)
assert len(result) == 1
assert responses.assert_call_count(url, 3) is True
@@ -549,7 +549,7 @@ def test_list_request_iterator_true_nowarning(gl):
def test_list_request_all_true_nowarning(gl):
responses.add(**large_list_response)
with warnings.catch_warnings(record=True) as caught_warnings:
- result = gl.http_list("/projects", all=True)
+ result = gl.http_list("/projects", get_all=True)
assert len(caught_warnings) == 0
assert isinstance(result, list)
assert len(result) == 20