oncall-engine/engine/apps/telegram/tests
Joey Orlando 0c96427cfc
fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851)
# What this PR does

It _appears_ like Telegram may have changed one of the error messages
they return for `telegram.error.BadRequest`. This _may_ be causing us to
infinitely retry some of these tasks.

Previously we were checking for two variants of the same type of error
message:
- "Message to reply not found"
- "Replied message not found"

_However_, if I search for the following [in the
logs](https://ops.grafana-ops.net/goto/hMgBb8CSR?orgId=1):
```logql
{namespace="amixr-prod"} |~ `(Message to be replied not found|Message to reply not found|Replied message not found)`
````
I _only_ see references to "Message to be replied not found". I have
updated references to the former to this new error log message we are
seeing.

Also:
- deduplicate some of the words we check for in
`telegram.error.BadRequest` and `telegram.error.Unauthorized` into
`apps.telegram.client.TelegramClient.BadRequestMessage` and
`apps.telegram.client.TelegramClient.UnauthorizedMessage` respectively
- deduplicate some of the wording we use in the `reason` arg passed to
`TelegramToUserConnector.create_telegram_notification_error` into
`apps.telegram.models.connectors.personal.TelegramToUserConnector.NotificationErrorReason`
- standardize how we check the `message` attribute of
`telegram.error.TelegramError`s into a new `error_message_is` static
method on `apps.telegram.client.TelegramClient`
- previously we would check these error messages in two different ways:
  ```python3
  # style 1
  if "error message to check" in e.message:
    # do something

  # style 2
  if error.message == "error message to check":
    # do something
  ```

## Which issue(s) this PR closes

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

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-19 14:05:40 -04:00
..
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
factories.py Add missing success log entries for personal notifications (#3557) 2023-12-14 18:32:26 +00:00
test_button_update_handler.py Handle alert group does not exist on telegram button press (#3814) 2024-02-01 17:55:35 +00:00
test_channel_connector.py Allow Telegram DMs without channel connection (#142) 2022-06-28 09:11:19 +01:00
test_keyboard_renderer.py Update alert group state by backsync (#4089) 2024-03-27 12:37:01 +00:00
test_message_renderer.py Fix docs and UI for connecting Grafana Alerting from other stack (#4243) 2024-04-24 08:02:51 +00:00
test_models.py Introduce org uuid (#947) 2022-12-06 22:42:58 +08:00
test_personal_connector.py fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
test_tasks.py fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
test_update_handlers.py Address deprecation warnings in tests (#4681) 2024-08-13 20:51:18 +00:00
test_webhook.py Address Telegram HTTP 500s when receiving message from Telegram in discussion group (#3622) 2024-01-09 08:31:56 -05:00