From 5a4aa0d8e7d18d92345ad1ca75b8ddda891a850c Mon Sep 17 00:00:00 2001 From: Kirill Chernakov Date: Tue, 22 Oct 2024 20:05:10 +0400 Subject: [PATCH] fix: assert merged and skipped incidents --- tests/test_incidents.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/test_incidents.py b/tests/test_incidents.py index 11110a1aa..b9c39a483 100644 --- a/tests/test_incidents.py +++ b/tests/test_incidents.py @@ -547,6 +547,9 @@ def test_merge_incidents_app( add_alerts_to_incident_by_incident_id( SINGLE_TENANT_UUID, incident_3.id, [a.id for a in alerts_3] ) + empty_incident = create_incident_from_dict( + SINGLE_TENANT_UUID, {"user_generated_name": "test-4", "user_summary": "test-4"} + ) incident_1_before_via_api = client.get( f"/incidents/{incident_1.id}", headers={"x-api-key": "some-key"} @@ -558,16 +561,28 @@ def test_merge_incidents_app( "/incidents/merge", headers={"x-api-key": "some-key"}, json={ - "source_incident_ids": [str(incident_2.id), str(incident_3.id)], + "source_incident_ids": [ + str(incident_2.id), + str(incident_3.id), + str(empty_incident.id), + ], "destination_incident_id": str(incident_1.id), }, ) assert response.status_code == 200 result = response.json() - assert result["id"] == str(incident_1.id) - assert result["alerts_count"] == 150 - assert "second-service" in result["services"] + assert result["merged_incident_ids"] == [str(incident_2.id), str(incident_3.id)] + assert result["skipped_incident_ids"] == [str(empty_incident.id)] + assert result["failed_incident_ids"] == [] + + incident_1_via_api = client.get( + f"/incidents/{incident_1.id}", headers={"x-api-key": "some-key"} + ).json() + + assert incident_1_via_api["id"] == str(incident_1.id) + assert incident_1_via_api["alerts_count"] == 150 + assert "second-service" in incident_1_via_api["services"] incident_2_via_api = client.get( f"/incidents/{incident_2.id}", headers={"x-api-key": "some-key"}