Skip to content
64 changes: 12 additions & 52 deletions tests/acceptance/standard/test_transfer_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@


class TestTransferProject:
def test__transfer_between_two_root_groups(self, project, group, other_group):
project_new_path_with_namespace = f"{other_group.path}/{project.name}"
def test__transfer_between_two_root_groups(
self, project_for_function, group, other_group
):
project_new_path_with_namespace = (
f"{other_group.path}/{project_for_function.name}"
)
projects_in_destination_before_transfer = other_group.projects.list()

config = f"""
projects_and_groups:
{project_new_path_with_namespace}:
project:
transfer_from: {project.path_with_namespace}
transfer_from: {project_for_function.path_with_namespace}
"""

run_gitlabform(config, project_new_path_with_namespace)
Expand All @@ -28,28 +32,6 @@ def test__transfer_between_two_root_groups(self, project, group, other_group):
== len(projects_in_destination_before_transfer) + 1
)

# Now test the transfer the opposite direction by transferring the same project back to the original group
# Transferring the project to the original location also helps because the fixtures used in this test is shared
# with other tests and they will need the fixture in its original form.
project_new_path_with_namespace = f"{group.path}/{project.name}"
project_source = f"{other_group.path}/{project.name}"
projects_in_destination_before_transfer = group.projects.list()

config = f"""
projects_and_groups:
{project_new_path_with_namespace}:
project:
transfer_from: {project_source}
"""

run_gitlabform(config, project_new_path_with_namespace)
projects_in_destination_after_transfer = group.projects.list()

assert (
len(projects_in_destination_after_transfer)
== len(projects_in_destination_before_transfer) + 1
)

def test__transfer_between_root_group_and_subgroup(
self, project_in_subgroup, group, subgroup
):
Expand All @@ -71,41 +53,19 @@ def test__transfer_between_root_group_and_subgroup(
== len(projects_in_destination_before_transfer) + 1
)

# Now test the transfer the opposite direction by transferring the same project back to the original group
# Transferring the project to the original location also helps because the fixtures used in this test is shared
# with other tests and they will need the fixture in its original form.
project_new_path_with_namespace = (
f"{group.path}/{subgroup.path}/{project_in_subgroup.name}"
)
project_source = f"{group.path}/{project_in_subgroup.name}"
projects_in_destination_before_transfer = subgroup.projects.list()

config = f"""
projects_and_groups:
{project_new_path_with_namespace}:
project:
transfer_from: {project_source}
"""

run_gitlabform(config, project_new_path_with_namespace)
projects_in_destination_after_transfer = subgroup.projects.list()

assert (
len(projects_in_destination_after_transfer)
== len(projects_in_destination_before_transfer) + 1
)

def test__transfer_as_same_path_at_namespae_already_exist(
self, project, group, other_group
self, project_for_function, group, other_group
):
project_new_path_with_namespace = f"{other_group.path}/{project.name}"
project_new_path_with_namespace = (
f"{other_group.path}/{project_for_function.name}"
)
projects_in_destination_before_transfer = other_group.projects.list()

config = f"""
projects_and_groups:
{project_new_path_with_namespace}:
project:
transfer_from: {project.path_with_namespace}
transfer_from: {project_for_function.path_with_namespace}
"""

run_gitlabform(config, project_new_path_with_namespace)
Expand Down