Skip to content

Commit

Permalink
removing tests for reconciliation_status fetching
Browse files Browse the repository at this point in the history
the status field is deprecated and the tests are failing randomly
  • Loading branch information
defreng committed Sep 11, 2023
1 parent 70faddd commit 2dd745f
Showing 1 changed file with 0 additions and 175 deletions.
175 changes: 0 additions & 175 deletions tests/e2e/hosters/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,6 @@ async def gitlab_hoster(gitlab_settings: GitlabTestSettings) -> Hoster:
return GitlabHoster(address=gitlab_settings.address, token=gitlab_settings.token.get_secret_value())


async def test_get_reconciliation_status_returns_success_for_default_branch_commit_without_pipeline(
gitlab_hoster: Hoster, gitlab_project: RepositoryTestData
):
# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_main,
merge_request_id=None,
)

# THEN
assert status == ReconciliationStatus.SUCCESS


async def test_get_reconciliation_status_returns_pending_for_default_branch_commit_with_pending_pipeline(
gitlab_hoster: Hoster, gitlab_project: RepositoryTestData
):
# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_branch_with_pipeline,
merge_request_id=None,
pipeline_timeout=timedelta(seconds=10),
)

# THEN
assert status == ReconciliationStatus.PENDING


async def test_get_merge_request_status_returns_open_for_open_merge_request(
gitlab_hoster: Hoster, gitlab_client: Client, gitlab_project: RepositoryTestData
):
Expand Down Expand Up @@ -200,147 +169,3 @@ async def test_get_merge_request_status_returns_closed_for_closed_merge_request(

# THEN
assert status == MergeRequestStatus.CLOSED


async def test_get_reconciliation_status_returns_pending_for_open_merge_request(
gitlab_hoster: Hoster, gitlab_client: Client, gitlab_project: RepositoryTestData
):
# GIVEN
response = gitlab_client.post(
f"/projects/{gitlab_project.project['id']}/merge_requests",
json={
"source_branch": "without-pipeline",
"target_branch": gitlab_project.project["default_branch"],
"title": "Some merge request",
},
)
response.raise_for_status()
merge_request = response.json()

# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_branch_without_pipeline,
merge_request_id=merge_request["iid"],
)

# THEN
assert status == ReconciliationStatus.PENDING


async def test_get_reconciliation_status_return_success_for_merged_merge_request_without_pipeline_in_target_branch(
gitlab_hoster: Hoster, gitlab_client: Client, gitlab_project: RepositoryTestData
):
# GIVEN
response = gitlab_client.post(
f"/projects/{gitlab_project.project['id']}/merge_requests",
json={
"source_branch": "without-pipeline",
"target_branch": gitlab_project.project["default_branch"],
"title": "Some merge request",
},
)
response.raise_for_status()
merge_request = response.json()

@retry(
retry=retry_if_exception_type(HTTPStatusError),
stop=stop_after_delay(10),
wait=wait_fixed(1),
)
async def __merge():
(
gitlab_client.put(
f"/projects/{gitlab_project.project['id']}/merge_requests/{merge_request['iid']}/merge",
)
).raise_for_status()

await __merge()

# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_branch_without_pipeline,
merge_request_id=merge_request["iid"],
)

# THEN
assert status == ReconciliationStatus.SUCCESS


async def test_get_reconciliation_status_return_success_for_merged_merge_request_without_merge_commit_and_without_pipeline_in_target_branch( # noqa: B950
gitlab_hoster: Hoster, gitlab_client: Client, gitlab_project: RepositoryTestData
):
# GIVEN
(gitlab_client.put(f"/projects/{gitlab_project.project['id']}", json={"merge_method": "ff"})).raise_for_status()

response = gitlab_client.post(
f"/projects/{gitlab_project.project['id']}/merge_requests",
json={
"source_branch": "without-pipeline",
"target_branch": gitlab_project.project["default_branch"],
"title": "Some merge request",
},
)
response.raise_for_status()
merge_request = response.json()

@retry(
retry=retry_if_exception_type(HTTPStatusError),
stop=stop_after_delay(10),
wait=wait_fixed(1),
)
async def __merge():
(
gitlab_client.put(
f"/projects/{gitlab_project.project['id']}/merge_requests/{merge_request['iid']}/merge",
)
).raise_for_status()

await __merge()

# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_branch_without_pipeline,
merge_request_id=merge_request["iid"],
)

# THEN
assert status == ReconciliationStatus.SUCCESS


async def test_get_reconciliation_status_returns_failed_for_closed_merge_request(
gitlab_hoster: Hoster, gitlab_client: Client, gitlab_project: RepositoryTestData
):
# GIVEN
response = gitlab_client.post(
f"/projects/{gitlab_project.project['id']}/merge_requests",
json={
"source_branch": "without-pipeline",
"target_branch": gitlab_project.project["default_branch"],
"title": "Some merge request",
},
)
response.raise_for_status()
merge_request = response.json()
(
gitlab_client.put(
f"/projects/{gitlab_project.project['id']}/merge_requests/{merge_request['iid']}",
json={"state_event": "close"},
)
).raise_for_status()

# WHEN
status = await gitlab_hoster.get_reconciliation_status(
incarnation_repository=gitlab_project.project["path_with_namespace"],
target_directory=".",
commit_sha=gitlab_project.commit_sha_branch_without_pipeline,
merge_request_id=merge_request["iid"],
)

# THEN
assert status == ReconciliationStatus.FAILED

0 comments on commit 2dd745f

Please sign in to comment.