def test_simple(self): self.create_event(self.now - timedelta(minutes=2)) self.create_event(self.now - timedelta(minutes=2)) self.create_event(self.now - timedelta(minutes=1)) incident = self.create_incident( date_started=self.now - timedelta(minutes=5), query="", projects=[self.project] ) snapshot = create_event_stat_snapshot(incident, windowed_stats=False) assert snapshot.start == incident.date_started - timedelta(minutes=1) assert snapshot.end == incident.current_end_date assert [row[1] for row in snapshot.values] == [2, 1] snapshot = create_event_stat_snapshot(incident, windowed_stats=True) expected_start, expected_end = calculate_incident_time_range(incident, windowed_stats=True) assert snapshot.start == expected_start assert snapshot.end == expected_end assert [row[1] for row in snapshot.values] == [2, 1]
def test_simple(self): self.create_event(self.now - timedelta(minutes=2)) self.create_event(self.now - timedelta(minutes=2)) self.create_event(self.now - timedelta(minutes=1)) incident = self.create_incident(date_started=self.now - timedelta(minutes=5), query="", projects=[self.project]) snapshot = create_event_stat_snapshot(incident, incident.date_started, incident.current_end_date) assert snapshot.start == incident.date_started assert snapshot.end == incident.current_end_date assert [row[1] for row in snapshot.values] == [2, 1]
def test_windowed(self): incident = self.create_incident(self.organization) incident.update(status=IncidentStatus.CLOSED.value) snapshot = create_incident_snapshot(incident, windowed_stats=True) expected_snapshot = create_event_stat_snapshot(incident, windowed_stats=True) assert snapshot.event_stats_snapshot.start == expected_snapshot.start assert snapshot.event_stats_snapshot.end == expected_snapshot.end assert snapshot.event_stats_snapshot.values == expected_snapshot.values assert snapshot.event_stats_snapshot.period == expected_snapshot.period assert snapshot.event_stats_snapshot.date_added == expected_snapshot.date_added aggregates = get_incident_aggregates(incident) assert snapshot.unique_users == aggregates["unique_users"] assert snapshot.total_events == aggregates["count"]
def test(self): incident = self.create_incident(self.organization) incident.update(status=IncidentStatus.CLOSED.value) snapshot = create_incident_snapshot(incident) expected_snapshot = create_event_stat_snapshot( incident, incident.date_started, incident.date_closed, ) assert snapshot.event_stats_snapshot.start == expected_snapshot.start assert snapshot.event_stats_snapshot.end == expected_snapshot.end assert snapshot.event_stats_snapshot.values == expected_snapshot.values assert snapshot.event_stats_snapshot.period == expected_snapshot.period assert snapshot.event_stats_snapshot.date_added == expected_snapshot.date_added aggregates = get_incident_aggregates(incident) assert snapshot.unique_users == aggregates['unique_users'] assert snapshot.total_events == aggregates['count']