|
17 | 17 | AlertRuleSensitivity,
|
18 | 18 | )
|
19 | 19 | from sentry.incidents.models.incident import IncidentStatus
|
20 |
| -from sentry.incidents.typings.metric_detector import AlertContext |
| 20 | +from sentry.incidents.typings.metric_detector import AlertContext, MetricIssueContext |
21 | 21 | from sentry.integrations.messaging.message_builder import (
|
22 | 22 | build_attachment_text,
|
23 | 23 | build_attachment_title,
|
@@ -807,11 +807,10 @@ def test_no_description_in_notification(self):
|
807 | 807 | )
|
808 | 808 | assert SlackIncidentsMessageBuilder(
|
809 | 809 | alert_context=AlertContext.from_alert_rule_incident(alert_rule),
|
810 |
| - open_period_identifier=incident.identifier, |
| 810 | + metric_issue_context=MetricIssueContext.from_legacy_models( |
| 811 | + incident, IncidentStatus.CRITICAL, 0 |
| 812 | + ), |
811 | 813 | organization=self.organization,
|
812 |
| - snuba_query=alert_rule.snuba_query, |
813 |
| - new_status=IncidentStatus.CRITICAL, |
814 |
| - metric_value=0, |
815 | 814 | date_started=incident.date_started,
|
816 | 815 | ).build() == {
|
817 | 816 | "blocks": [
|
@@ -879,12 +878,11 @@ def test_simple(self):
|
879 | 878 | )
|
880 | 879 | assert SlackIncidentsMessageBuilder(
|
881 | 880 | alert_context=AlertContext.from_alert_rule_incident(alert_rule),
|
882 |
| - open_period_identifier=incident.identifier, |
| 881 | + metric_issue_context=MetricIssueContext.from_legacy_models( |
| 882 | + incident, IncidentStatus.CLOSED, 0 |
| 883 | + ), |
883 | 884 | organization=self.organization,
|
884 |
| - snuba_query=alert_rule.snuba_query, |
885 | 885 | date_started=incident.date_started,
|
886 |
| - new_status=IncidentStatus.CLOSED, |
887 |
| - metric_value=0, |
888 | 886 | ).build() == {
|
889 | 887 | "blocks": [
|
890 | 888 | {
|
@@ -924,11 +922,10 @@ def test_metric_value(self):
|
924 | 922 | # This should fail because it pulls status from `action` instead of `incident`
|
925 | 923 | assert SlackIncidentsMessageBuilder(
|
926 | 924 | alert_context=AlertContext.from_alert_rule_incident(alert_rule),
|
927 |
| - open_period_identifier=incident.identifier, |
| 925 | + metric_issue_context=MetricIssueContext.from_legacy_models( |
| 926 | + incident, IncidentStatus.CRITICAL, metric_value |
| 927 | + ), |
928 | 928 | organization=self.organization,
|
929 |
| - snuba_query=alert_rule.snuba_query, |
930 |
| - new_status=IncidentStatus.CRITICAL, |
931 |
| - metric_value=metric_value, |
932 | 929 | date_started=incident.date_started,
|
933 | 930 | ).build() == {
|
934 | 931 | "blocks": [
|
@@ -965,11 +962,10 @@ def test_chart(self):
|
965 | 962 | )
|
966 | 963 | assert SlackIncidentsMessageBuilder(
|
967 | 964 | alert_context=AlertContext.from_alert_rule_incident(alert_rule),
|
968 |
| - open_period_identifier=incident.identifier, |
| 965 | + metric_issue_context=MetricIssueContext.from_legacy_models( |
| 966 | + incident, IncidentStatus.CLOSED, 0 |
| 967 | + ), |
969 | 968 | organization=self.organization,
|
970 |
| - snuba_query=alert_rule.snuba_query, |
971 |
| - new_status=IncidentStatus.CLOSED, |
972 |
| - metric_value=0, |
973 | 969 | date_started=incident.date_started,
|
974 | 970 | chart_url="chart-url",
|
975 | 971 | ).build() == {
|
@@ -1021,11 +1017,10 @@ def test_metric_alert_with_anomaly_detection(self, mock_seer_request):
|
1021 | 1017 | )
|
1022 | 1018 | assert SlackIncidentsMessageBuilder(
|
1023 | 1019 | alert_context=AlertContext.from_alert_rule_incident(alert_rule),
|
1024 |
| - open_period_identifier=incident.identifier, |
| 1020 | + metric_issue_context=MetricIssueContext.from_legacy_models( |
| 1021 | + incident, IncidentStatus.CRITICAL, 0 |
| 1022 | + ), |
1025 | 1023 | organization=self.organization,
|
1026 |
| - snuba_query=alert_rule.snuba_query, |
1027 |
| - new_status=IncidentStatus.CRITICAL, |
1028 |
| - metric_value=0, |
1029 | 1024 | date_started=incident.date_started,
|
1030 | 1025 | ).build() == {
|
1031 | 1026 | "blocks": [
|
|
0 commit comments