oncall-engine/engine/apps/slack/tests/test_slack_formatter.py
Yulya Artyukhina 863af25994
Fix alert group rendering (#3424)
# What this PR does
Fix alert group rendering when some links were broken because of
replacing `-` to `_`.

## Which issue(s) this PR fixes
https://github.com/grafana/support-escalations/issues/8119
https://github.com/grafana/support-escalations/issues/8468

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-24 15:39:37 +00:00

16 lines
661 B
Python

from unittest.mock import MagicMock
import pytest
from apps.slack.slack_formatter import SlackFormatter
@pytest.mark.django_db
def test_slack_to_accepted_emoji():
sf = SlackFormatter(MagicMock())
test_message = """[:book: Runbook:link:](https://example-test.com/explore?panes=%7B:%7Bname-with-dash%22:%22FE%22:%5B%7B%22another-one%22:namespace-with-dash)
Test emoji :male-construction-worker:https://another-example.com/test:=%22-dash
:female-construction-worker:"""
expected_result = test_message.replace("-construction-worker", "_construction_worker")
result = sf.slack_to_accepted_emoji(test_message)
assert result == expected_result