def test_normal(self): event = self.store_event(data={}, project_id=self.project.id) rule = Rule.objects.create(project=self.project, label="my rule") futures = [RuleFuture(rule, {})] with mock.patch.object(self.adapter, "notify") as notify: self.adapter.rule_notify(event, futures, ActionTargetType.ISSUE_OWNERS) notify.call_count == 1
def test_digest(self, digests): digests.enabled.return_value = True event = self.store_event(data={}, project_id=self.project.id) rule = Rule.objects.create(project=self.project, label="my rule") futures = [RuleFuture(rule, {})] self.adapter.rule_notify(event, futures, ActionTargetType.ISSUE_OWNERS) digests.add.call_count == 1
def test_digest_enabled(self, digests, mock_func): """ Test that with digests enabled, but Slack notification settings (and not email settings), we send a Slack notification """ digests.enabled.return_value = True event = self.store_event( data={"message": "Hello world", "level": "error"}, project_id=self.project.id ) rule = Rule.objects.create(project=self.project, label="my rule") futures = [RuleFuture(rule, {})] self.adapter.rule_notify(event, futures, ActionTargetType.MEMBER, self.user.id) assert digests.call_count == 0 attachment = get_attachment() assert attachment["title"] == "Hello world" assert attachment["text"] == "" assert attachment["footer"] == event.group.qualified_short_id