Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/functional/api/test_epics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ def test_epics(group):
assert group.epics.list()


@pytest.mark.xfail(reason="404 on issue.id")
def test_epic_issues(epic, issue):
assert not epic.issues.list()

# FYI: Creating an issue causes a note to be created
epic_issue = epic.issues.create({"issue_id": issue.id})
assert epic.issues.list()

# FYI: Deleting an issue causes a note to be created
epic_issue.delete()


def test_epic_notes(epic):
assert not epic.notes.list()
notes = epic.notes.list(get_all=True)

epic.notes.create({"body": "Test note"})
assert epic.notes.list()
new_notes = epic.notes.list(get_all=True)
assert len(new_notes) == (len(notes) + 1), f"{new_notes} {notes}"
10 changes: 9 additions & 1 deletion tests/functional/api/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def test_keys_deploy(gl, project, DEPLOY_KEY):
key_by_fingerprint = gl.keys.get(fingerprint=fingerprint)
assert key_by_fingerprint.title == key.title
assert key_by_fingerprint.key == key.key
assert len(key_by_fingerprint.deploy_keys_projects) == 1

for key_project in key_by_fingerprint.deploy_keys_projects:
if key_project.get("project_id") == project.id:
break
else:
raise AssertionError(
f"Project {project} not found in 'deploy_keys_projects' "
f"{key_by_fingerprint.pformat()}"
)

key.delete()
4 changes: 4 additions & 0 deletions tests/functional/api/test_project_job_token_scope.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pytest


# https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html#allow-any-project-to-access-your-project
def test_enable_limit_access_to_this_project(gl, project):
scope = project.job_token_scope.get()
Expand All @@ -10,6 +13,7 @@ def test_enable_limit_access_to_this_project(gl, project):
assert scope.inbound_enabled


@pytest.mark.xfail(reason="https://gitlab.com/gitlab-org/gitlab/-/issues/582271")
def test_disable_limit_access_to_this_project(gl, project):
scope = project.job_token_scope.get()

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/api/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def test_create_project(gl, user):

sudo_project = gl.projects.create({"name": "sudo_project"}, sudo=user.id)

created = gl.projects.list()
created = gl.projects.list(get_all=True)
created_gen = gl.projects.list(iterator=True)
owned = gl.projects.list(owned=True)
owned = gl.projects.list(owned=True, get_all=True)

assert admin_project in created and sudo_project in created
assert admin_project in owned and sudo_project not in owned
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/fixtures/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GITLAB_IMAGE=gitlab/gitlab-ee
GITLAB_TAG=17.8.2-ee.0
GITLAB_TAG=18.6.1-ee.0
GITLAB_RUNNER_IMAGE=gitlab/gitlab-runner
GITLAB_RUNNER_TAG=96856197
2 changes: 1 addition & 1 deletion tests/functional/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
entrypoint:
- /bin/sh
- -c
- ruby /create_license.rb && /assets/wrapper
- ruby /create_license.rb && /assets/init-container
volumes:
- ${PWD}/tests/functional/fixtures/create_license.rb:/create_license.rb
ports:
Expand Down
22 changes: 11 additions & 11 deletions tests/functional/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gitlab
import gitlab.base
import gitlab.exceptions
import gitlab.v4.objects

SLEEP_INTERVAL = 0.5
TIMEOUT = 60 # seconds before timeout will occur
Expand Down Expand Up @@ -37,6 +38,11 @@ def safe_delete(object: gitlab.base.RESTObject) -> None:
object = manager.get(object.get_id()) # type: ignore[attr-defined]
except gitlab.exceptions.GitlabGetError:
return
# If object is already marked for deletion we have succeeded
if getattr(object, "marked_for_deletion_on", None) is not None:
# 'Group' and 'Project' objects have a 'marked_for_deletion_on' attribute
logging.info(f"{object!r} is marked for deletion.")
return

if index:
logging.info(f"Attempt {index + 1} to delete {object!r}.")
Expand All @@ -52,22 +58,16 @@ def safe_delete(object: gitlab.base.RESTObject) -> None:
# we shouldn't cause test to fail if it still exists
return
elif isinstance(object, gitlab.v4.objects.Project):
# Immediately delete rather than waiting for at least 1day
# https://docs.gitlab.com/ee/api/projects.html#delete-project
object.delete(permanently_remove=True)
pass
# Starting in GitLab 18, projects can't be immediately deleted.
# So this will mark it for deletion.
object.delete()
else:
# We only attempt to delete parent groups to prevent dangling sub-groups
# However parent groups can only be deleted on a delay in Gl 16
# However parent groups can only be deleted on a delay in GitLab 16
# https://docs.gitlab.com/ee/api/groups.html#remove-group
object.delete()
except gitlab.exceptions.GitlabDeleteError:
logging.info(f"{object!r} already deleted or scheduled for deletion.")
if isinstance(object, gitlab.v4.objects.Group):
# Parent groups can never be immediately deleted in GL 16,
# so don't cause test to fail if it still exists
return
pass
logging.exception(f"Error attempting to delete: {object.pformat()}")

time.sleep(SLEEP_INTERVAL)
pytest.fail(f"{object!r} was not deleted")