1
+ from typing import Any
1
2
from unittest .mock import patch
2
3
3
4
from django .utils import timezone
12
13
13
14
14
15
class IncidentGroupOpenPeriodTest (TestCase ):
15
- def setUp (self ):
16
+ def setUp (self ) -> None :
16
17
super ().setUp ()
17
18
self .organization = self .create_organization ()
18
19
self .project = self .create_project (organization = self .organization )
@@ -25,7 +26,7 @@ def setUp(self):
25
26
self .group .type = MetricIssue .type_id
26
27
self .group .save ()
27
28
28
- def save_issue_occurrence (self , group_type = MetricIssue , include_alert_id = True ):
29
+ def save_issue_occurrence (self , include_alert_id : bool = True ) -> tuple [ Any , GroupOpenPeriod ] :
29
30
event = self .store_event (
30
31
data = {"timestamp" : timezone .now ().isoformat ()}, project_id = self .project .id
31
32
)
@@ -42,7 +43,7 @@ def save_issue_occurrence(self, group_type=MetricIssue, include_alert_id=True):
42
43
"evidence_display" : [
43
44
{"name" : "Test Evidence" , "value" : "Test Value" , "important" : True }
44
45
],
45
- "type" : group_type .type_id ,
46
+ "type" : MetricIssue .type_id ,
46
47
"detection_time" : timezone .now ().timestamp (),
47
48
"level" : "error" ,
48
49
"culprit" : "test-culprit" ,
@@ -52,15 +53,15 @@ def save_issue_occurrence(self, group_type=MetricIssue, include_alert_id=True):
52
53
occurrence , group_info = save_issue_occurrence (occurrence_data , event )
53
54
54
55
assert group_info is not None
55
- assert group_info .group .type == group_type .type_id
56
+ assert group_info .group .type == MetricIssue .type_id
56
57
57
58
open_period = GroupOpenPeriod .objects .get (group = group_info .group )
58
59
assert open_period is not None
59
60
assert open_period .date_ended is None
60
61
return occurrence , open_period
61
62
62
63
@with_feature ("organizations:issue-open-periods" )
63
- def test_create_from_occurrence_with_existing_incident (self ):
64
+ def test_create_from_occurrence_with_existing_incident (self ) -> None :
64
65
"""Test creating relationship when incident exists"""
65
66
occurrence , open_period = self .save_issue_occurrence ()
66
67
@@ -79,7 +80,7 @@ def test_create_from_occurrence_with_existing_incident(self):
79
80
assert result .group_open_period == open_period
80
81
81
82
@with_feature ("organizations:issue-open-periods" )
82
- def test_create_from_occurrence_without_incident (self ):
83
+ def test_create_from_occurrence_without_incident (self ) -> None :
83
84
"""Test creating placeholder when incident doesn't exist"""
84
85
occurrence , open_period = self .save_issue_occurrence ()
85
86
@@ -90,7 +91,7 @@ def test_create_from_occurrence_without_incident(self):
90
91
assert open_period .data ["pending_incident_alert_id" ] == self .alert_rule .id
91
92
92
93
@with_feature ("organizations:issue-open-periods" )
93
- def test_create_from_occurrence_no_alert_id (self ):
94
+ def test_create_from_occurrence_no_alert_id (self ) -> None :
94
95
"""Test handling when no alert_id in evidence_data"""
95
96
with patch ("sentry.issues.ingest.eventstream" ) as _ :
96
97
occurrence , group_info = self .save_issue_occurrence (include_alert_id = False )
@@ -105,7 +106,7 @@ def test_create_from_occurrence_no_alert_id(self):
105
106
assert result is None
106
107
107
108
@with_feature ("organizations:issue-open-periods" )
108
- def test_create_relationship_new (self ):
109
+ def test_create_relationship_new (self ) -> None :
109
110
"""Test creating a new relationship"""
110
111
occurrence , open_period = self .save_issue_occurrence ()
111
112
@@ -124,7 +125,7 @@ def test_create_relationship_new(self):
124
125
assert result .group_open_period == open_period
125
126
126
127
@with_feature ("organizations:issue-open-periods" )
127
- def test_create_relationship_existing (self ):
128
+ def test_create_relationship_existing (self ) -> None :
128
129
"""Test updating an existing relationship"""
129
130
occurrence , open_period = self .save_issue_occurrence ()
130
131
@@ -155,7 +156,7 @@ def test_create_relationship_existing(self):
155
156
assert result .group_open_period == open_period
156
157
157
158
@with_feature ("organizations:issue-open-periods" )
158
- def test_create_placeholder_relationship (self ):
159
+ def test_create_placeholder_relationship (self ) -> None :
159
160
"""Test creating a placeholder relationship"""
160
161
occurrence , open_period = self .save_issue_occurrence ()
161
162
@@ -168,7 +169,7 @@ def test_create_placeholder_relationship(self):
168
169
assert open_period .data ["pending_incident_alert_id" ] == self .alert_rule .id
169
170
170
171
@with_feature ("organizations:issue-open-periods" )
171
- def test_create_pending_relationships_for_incident (self ):
172
+ def test_create_pending_relationships_for_incident (self ) -> None :
172
173
"""Test creating relationships for pending open periods"""
173
174
occurrence , open_period = self .save_issue_occurrence ()
174
175
@@ -195,7 +196,7 @@ def test_create_pending_relationships_for_incident(self):
195
196
assert "pending_incident_alert_id" not in open_period .data
196
197
197
198
@with_feature ("organizations:issue-open-periods" )
198
- def test_create_pending_relationships_for_incident_no_pending (self ):
199
+ def test_create_pending_relationships_for_incident_no_pending (self ) -> None :
199
200
"""Test creating relationships when no pending relationships exist"""
200
201
incident = self .create_incident (
201
202
organization = self .organization ,
0 commit comments