|
@@ -1425,6 +1425,46 @@ class CreateAlertRuleTriggerActionTest(BaseAlertRuleTriggerActionTest, TestCase)
|
|
|
integration_id=integration.id,
|
|
|
)
|
|
|
|
|
|
+ @responses.activate
|
|
|
+ def test_discord(self):
|
|
|
+ base_url: str = "https://discord.com/api/v10"
|
|
|
+ channel_id = "channel-id"
|
|
|
+ guild_id = "example-discord-server"
|
|
|
+ guild_name = "Server Name"
|
|
|
+ integration = Integration.objects.create(
|
|
|
+ provider="discord",
|
|
|
+ name="Example Discord",
|
|
|
+ external_id=f"{guild_id}",
|
|
|
+ metadata={
|
|
|
+ "guild_id": f"{guild_id}",
|
|
|
+ "name": f"{guild_name}",
|
|
|
+ },
|
|
|
+ )
|
|
|
+ type = AlertRuleTriggerAction.Type.DISCORD
|
|
|
+ target_type = AlertRuleTriggerAction.TargetType.SPECIFIC
|
|
|
+ responses.add(
|
|
|
+ method=responses.GET,
|
|
|
+ url=f"{base_url}/channels/{channel_id}",
|
|
|
+ json={
|
|
|
+ "guild_id": f"{guild_id}",
|
|
|
+ "name": f"{guild_name}",
|
|
|
+ },
|
|
|
+ )
|
|
|
+ with self.feature("organizations:integrations-discord-metric-alerts"):
|
|
|
+ action = create_alert_rule_trigger_action(
|
|
|
+ self.trigger,
|
|
|
+ type,
|
|
|
+ target_type,
|
|
|
+ target_identifier=channel_id,
|
|
|
+ integration_id=integration.id,
|
|
|
+ )
|
|
|
+ assert action.alert_rule_trigger == self.trigger
|
|
|
+ assert action.type == type.value
|
|
|
+ assert action.target_type == target_type.value
|
|
|
+ assert action.target_identifier == channel_id
|
|
|
+ assert action.target_display == channel_id
|
|
|
+ assert action.integration_id == integration.id
|
|
|
+
|
|
|
|
|
|
class UpdateAlertRuleTriggerAction(BaseAlertRuleTriggerActionTest, TestCase):
|
|
|
@cached_property
|
|
@@ -1723,6 +1763,50 @@ class UpdateAlertRuleTriggerAction(BaseAlertRuleTriggerActionTest, TestCase):
|
|
|
integration_id=integration.id,
|
|
|
)
|
|
|
|
|
|
+ @responses.activate
|
|
|
+ def test_discord(self):
|
|
|
+ base_url: str = "https://discord.com/api/v10"
|
|
|
+ channel_id = "channel-id"
|
|
|
+ guild_id = "example-discord-server"
|
|
|
+ guild_name = "Server Name"
|
|
|
+
|
|
|
+ integration = Integration.objects.create(
|
|
|
+ provider="discord",
|
|
|
+ name="Example Discord",
|
|
|
+ external_id=f"{guild_id}",
|
|
|
+ metadata={
|
|
|
+ "guild_id": f"{guild_id}",
|
|
|
+ "name": f"{guild_name}",
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ integration.add_organization(self.organization, self.user)
|
|
|
+ type = AlertRuleTriggerAction.Type.DISCORD
|
|
|
+ target_type = AlertRuleTriggerAction.TargetType.SPECIFIC
|
|
|
+ responses.add(
|
|
|
+ method=responses.GET,
|
|
|
+ url=f"{base_url}/channels/{channel_id}",
|
|
|
+ json={
|
|
|
+ "guild_id": f"{guild_id}",
|
|
|
+ "name": f"{guild_name}",
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ with self.feature("organizations:integrations-discord-metric-alerts"):
|
|
|
+ action = update_alert_rule_trigger_action(
|
|
|
+ self.action,
|
|
|
+ type,
|
|
|
+ target_type,
|
|
|
+ target_identifier=channel_id,
|
|
|
+ integration_id=integration.id,
|
|
|
+ )
|
|
|
+ assert action.alert_rule_trigger == self.trigger
|
|
|
+ assert action.type == type.value
|
|
|
+ assert action.target_type == target_type.value
|
|
|
+ assert action.target_identifier == channel_id
|
|
|
+ assert action.target_display == channel_id
|
|
|
+ assert action.integration_id == integration.id
|
|
|
+
|
|
|
|
|
|
class DeleteAlertRuleTriggerAction(BaseAlertRuleTriggerActionTest, TestCase):
|
|
|
@cached_property
|