コード例 #1
0
ファイル: test_tasks.py プロジェクト: zlcoming/sentry
    def test_task_existing_metric_alert(self, mock_get_channel_id,
                                        mock_set_value):
        alert_rule_data = self.metic_alert_data
        alert_rule = self.create_alert_rule(organization=self.org,
                                            projects=[self.project1],
                                            name="New Rule",
                                            user=self.user)

        data = {
            "data": alert_rule_data,
            "uuid": self.uuid,
            "organization_id": self.org.id,
            "alert_rule_id": alert_rule.id,
        }

        with self.tasks():
            with self.feature(["organizations:incidents"]):
                find_channel_id_for_alert_rule(**data)

        rule = AlertRule.objects.get(name="New Rule")
        mock_set_value.assert_called_with("success", rule.id)
        mock_get_channel_id.assert_called_with(self.integration, "my-channel",
                                               180)

        trigger_action = AlertRuleTriggerAction.objects.get(
            integration=self.integration.id)
        assert trigger_action.target_identifier == "chan-id"
        assert AlertRule.objects.get(id=alert_rule.id)
コード例 #2
0
ファイル: test_tasks.py プロジェクト: waterdrops/sentry
    def test_task_timeout_id_lookup(self, mock_get_channel_id, mock_set_value):
        alert_rule_data = self.metric_alert_data

        data = {
            "data": alert_rule_data,
            "uuid": self.uuid,
            "organization_id": self.org.id,
        }

        with self.tasks():
            with self.feature(["organizations:incidents"]):
                find_channel_id_for_alert_rule(**data)

        assert not AlertRule.objects.filter(name="New Rule").exists()
        mock_set_value.assert_called_with("failed")
        mock_get_channel_id.assert_called_with(self.integration, "my-channel", 180)
コード例 #3
0
ファイル: test_tasks.py プロジェクト: waterdrops/sentry
    def test_task_new_alert_rule(self, mock_get_channel_id, mock_set_value):
        alert_rule_data = self.metric_alert_data

        data = {
            "data": alert_rule_data,
            "uuid": self.uuid,
            "organization_id": self.org.id,
            "user_id": self.user.id,
        }

        with self.tasks():
            with self.feature(["organizations:incidents"]):
                find_channel_id_for_alert_rule(**data)

        rule = AlertRule.objects.get(name="New Rule")
        assert rule.created_by == self.user
        mock_set_value.assert_called_with("success", rule.id)
        mock_get_channel_id.assert_called_with(self.integration, "my-channel", 180)

        trigger_action = AlertRuleTriggerAction.objects.get(integration=self.integration.id)
        assert trigger_action.target_identifier == "chan-id"