oncall-engine/engine/common/tests
Joey Orlando 06933a696a
Support alert routing based on labels (#3778)
# What this PR does

This PR adds support for routing alerts based on labels.
https://www.loom.com/share/4401de6e3c4945d5b8961fe43ee373c9

Additionally:
- improve the typing around the `get_object` method that is inherited by
[`PublicPrimaryKeyMixin.get_object`](https://github.com/grafana/oncall/blob/dev/engine/common/api_helpers/mixins.py#L153)
in most of our models. `PublicPrimaryKeyMixin` is generic, so it can be
more strongly typed when it is being subclassed, which results in better
typing of the `get_object` method in child classes
- I decided to do this because I started looking into this task via the
[`AlertReceiveChannelView.send_demo_alert`
method/endpoint](https://github.com/grafana/oncall/blob/dev/engine/apps/api/views/alert_receive_channel.py#L242).
Within that method, `instance` is not typed because the inherited
`get_object` method is not typed.. I digress 😄
- improve typing around `Alert.create` and
`apps.integrations.tasks.create_alert` functions
- make `Alert.render_group_data` more DRY by extracting some logic out
into `Alert._apply_jinja_template_to_alert_payload_and_labels`
- deduplicate the logic of `value.strip().lower() in ["1", "true",
"ok"]` into a shared function,
`common.jinja_templater.apply_jinja_template.templated_value_is_truthy`

Closes https://github.com/grafana/oncall-private/issues/2490

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
- [x] Documentation added (or `pr:no public docs` PR label added if not
required) (will be done in #3762)
2024-01-30 13:07:19 -05:00
..
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
test_apply_jinja_template.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
test_cache.py patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
test_create_engine_url.py Use utility function to create URLs 2022-07-12 15:42:20 -06:00
test_custom_fields.py shift swap requests model + CRUD endpoints (#2597) 2023-07-21 19:35:19 +00:00
test_database.py Add utility function to get readonly db key if defined (#1264) 2023-02-01 12:07:32 +01:00
test_l10n.py add user locale field to mobile app user settings table + change going on call push notification text (#2131) 2023-06-14 12:19:58 -04:00
test_markup.py Fix cuddled list Markdown issue (#2488) 2023-07-11 09:14:52 +00:00
test_ordered_model.py Enable flake8-bugbear, fix issues (#3454) 2023-11-29 15:04:48 +00:00
test_recaptcha.py Add validation of hostname for recapctha (#1445) 2023-03-06 08:59:48 +00:00
test_regex_replace.py linting and fixed test 2022-07-14 20:06:24 +10:00
test_task_queue_assignment.py add more logging on celery task retry (#3695) 2024-01-16 07:13:16 -05:00
test_timezones.py shift swap requests model + CRUD endpoints (#2597) 2023-07-21 19:35:19 +00:00
test_urlize.py Fix warnings when running backend tests (#2079) 2023-06-06 18:38:00 +00:00
test_urlvalidator_without_tld.py use CustomURLValidator in custom_button (#1398) 2023-03-23 12:21:17 +00:00
test_viewset_actions.py Make viewset actions more consistent (#2120) 2023-06-07 12:10:53 +00:00