summaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-01-10 18:11:05 -0800
committerJohn L. Villalovos <john@sodarock.com>2022-01-13 10:31:24 -0800
commita2e7c383e10509b6eb0fa8760727036feb0807c8 (patch)
tree934b8e03c90239f1eaa80dcef347e0774ecb589f /tests/functional
parent12435d74364ca881373d690eab89d2e2baa62a49 (diff)
downloadgitlab-a2e7c383e10509b6eb0fa8760727036feb0807c8.tar.gz
chore: add EncodedId string class to use to hold URL-encoded paths
Add EncodedId string class. This class returns a URL-encoded string but ensures it will only URL-encode it once even if recursively called. Also added some functional tests of 'lazy' objects to make sure they work.
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/api/test_groups.py6
-rw-r--r--tests/functional/api/test_lazy_objects.py39
-rw-r--r--tests/functional/api/test_wikis.py1
-rw-r--r--tests/functional/conftest.py3
4 files changed, 47 insertions, 2 deletions
diff --git a/tests/functional/api/test_groups.py b/tests/functional/api/test_groups.py
index 77562c1..105acbb 100644
--- a/tests/functional/api/test_groups.py
+++ b/tests/functional/api/test_groups.py
@@ -100,6 +100,7 @@ def test_groups(gl):
member = group1.members.get(user2.id)
assert member.access_level == gitlab.const.OWNER_ACCESS
+ gl.auth()
group2.members.delete(gl.user.id)
@@ -198,6 +199,11 @@ def test_group_subgroups_projects(gl, user):
assert gr1_project.namespace["id"] == group1.id
assert gr2_project.namespace["parent_id"] == group1.id
+ gr1_project.delete()
+ gr2_project.delete()
+ group3.delete()
+ group4.delete()
+
@pytest.mark.skip
def test_group_wiki(group):
diff --git a/tests/functional/api/test_lazy_objects.py b/tests/functional/api/test_lazy_objects.py
new file mode 100644
index 0000000..3db7a60
--- /dev/null
+++ b/tests/functional/api/test_lazy_objects.py
@@ -0,0 +1,39 @@
+import pytest
+
+import gitlab
+
+
+@pytest.fixture
+def lazy_project(gl, project):
+ assert "/" in project.path_with_namespace
+ return gl.projects.get(project.path_with_namespace, lazy=True)
+
+
+def test_lazy_id(project, lazy_project):
+ assert isinstance(lazy_project.id, str)
+ assert isinstance(lazy_project.id, gitlab.utils.EncodedId)
+ assert lazy_project.id == gitlab.utils._url_encode(project.path_with_namespace)
+
+
+def test_refresh_after_lazy_get_with_path(project, lazy_project):
+ lazy_project.refresh()
+ assert lazy_project.id == project.id
+
+
+def test_save_after_lazy_get_with_path(project, lazy_project):
+ lazy_project.description = "A new description"
+ lazy_project.save()
+ assert lazy_project.id == project.id
+ assert lazy_project.description == "A new description"
+
+
+def test_delete_after_lazy_get_with_path(gl, group, wait_for_sidekiq):
+ project = gl.projects.create({"name": "lazy_project", "namespace_id": group.id})
+ result = wait_for_sidekiq(timeout=60)
+ assert result is True, "sidekiq process should have terminated but did not"
+ lazy_project = gl.projects.get(project.path_with_namespace, lazy=True)
+ lazy_project.delete()
+
+
+def test_list_children_after_lazy_get_with_path(gl, lazy_project):
+ lazy_project.mergerequests.list()
diff --git a/tests/functional/api/test_wikis.py b/tests/functional/api/test_wikis.py
index 26ac244..bcb5e1f 100644
--- a/tests/functional/api/test_wikis.py
+++ b/tests/functional/api/test_wikis.py
@@ -5,7 +5,6 @@ https://docs.gitlab.com/ee/api/wikis.html
def test_wikis(project):
-
page = project.wikis.create({"title": "title/subtitle", "content": "test content"})
page.content = "update content"
page.title = "subtitle"
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 8b25c6c..e788646 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -406,7 +406,8 @@ def user(gl):
yield user
try:
- user.delete()
+ # Use `hard_delete=True` or a 'Ghost User' may be created.
+ user.delete(hard_delete=True)
except gitlab.exceptions.GitlabDeleteError as e:
print(f"User already deleted: {e}")