Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix demo alert for inbound email #2081

Merged
merged 9 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make is_demo_alert_enabled and example_payload required
  • Loading branch information
vstpme committed Jun 1, 2023
commit cae0923b286f4dc9574cec56688b8d8422cc9b99
23 changes: 23 additions & 0 deletions engine/apps/alerts/tests/test_default_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,26 @@ def test_default_templates_are_valid():
jinja_template_env.from_string(template)
except TemplateSyntaxError as e:
pytest.fail(e.message)


@pytest.mark.parametrize("config", AlertReceiveChannel._config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice ✌️

def test_is_demo_alert_enabled(config):
# is_demo_alert_enabled must be defined
try:
assert isinstance(config.is_demo_alert_enabled, bool), "is_demo_alert_enabled must be bool"
except AttributeError:
pytest.fail("is_demo_alert_enabled must be defined")

# example_payload must be defined
try:
assert config.example_payload is None or isinstance(
config.example_payload, dict
), "example_payload must be dict or None"
except AttributeError:
pytest.fail("example_payload must be defined")

# example_payload must be provided when is_demo_alert_enabled is True
if config.is_demo_alert_enabled:
assert config.example_payload, "example_payload must be defined and non-empty"
else:
assert config.example_payload is None, "example_payload must be None if is_demo_alert_enabled is False"
2 changes: 2 additions & 0 deletions engine/config_integrations/direct_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@
resolve_condition = None

acknowledge_condition = None

example_payload = None
2 changes: 1 addition & 1 deletion engine/config_integrations/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

acknowledge_condition = None

example_payload = {"foo": "bar"}
example_payload = None
2 changes: 2 additions & 0 deletions engine/config_integrations/inbound_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
resolve_condition = '{{ payload.get("message", "").upper() == "OK" }}'

acknowledge_condition = None

example_payload = None
4 changes: 3 additions & 1 deletion engine/config_integrations/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
is_displayed_on_web = False
is_featured = False
is_able_to_autoresolve = False
is_demo_alert_enabled = True
is_demo_alert_enabled = False

description = None

Expand Down Expand Up @@ -45,3 +45,5 @@
resolve_condition = None

acknowledge_condition = None

example_payload = None
2 changes: 2 additions & 0 deletions engine/config_integrations/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@
resolve_condition = None

acknowledge_condition = None

example_payload = None
2 changes: 2 additions & 0 deletions engine/config_integrations/slack_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@
acknowledge_condition = None

source_link = '{{ payload.get("amixr_mixin", {}).get("permalink", "")}}'

example_payload = None