Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-C-Mitchell committed Sep 30, 2024
1 parent 9a274b7 commit e4afb06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ class Config(object):

EAS_EMAIL_REPLY_TO_ID = "591164ac-721d-46e5-b329-fe40f5253241"

REPORTS_SLACK_WEBHOOK_URL = ""

# as defined in api db migration 0331_add_broadcast_org.py
BROADCAST_ORGANISATION_ID = "38e4bf69-93b0-445d-acee-53ea53fe02df"

Expand Down Expand Up @@ -398,6 +396,8 @@ class Test(Config):
)
ADMIN_EXTERNAL_URL = f"https://{TENANT}admin.{SUBDOMAIN}emergency-alerts.service.gov.uk"

REPORTS_SLACK_WEBHOOK_URL = "https://hooks.slack.com/somewhere"

CBC_PROXY_ENABLED = True
DVLA_EMAIL_ADDRESSES = ["success@simulator.amazonses.com", "success+2@simulator.amazonses.com"]

Expand Down
26 changes: 6 additions & 20 deletions tests/app/reports/test_rest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from emergency_alerts_utils.clients.slack.slack_client import SlackMessage


def test_create_report(admin_request, mocker):
data = {
"type": "some-violation",
Expand All @@ -9,23 +6,12 @@ def test_create_report(admin_request, mocker):
"body": {"something": "random", "could_be": "anything"},
}

mock_send_message_to_slack = mocker.patch(
"app.slack_client.send_message_to_slack",
mock_log_report = mocker.patch(
"app.reports.rest.slack_client.send_message_to_slack",
autospec=True,
return_value={"message": "Slack message sent to the provided webhook URL."},
)

slack_message = SlackMessage(
webhook_url="",
subject="Reporting Endpoint Submission",
message_type="info",
markdown_sections=[
(
"*Type*: some-violation\n\n"
"*URL*: https://gov.uk\n\n"
"*User Agent*: some-browser\n\n"
'*Body*: ```{"something":"random","could_be":"anything"}```'
)
],
)
admin_request.post("reports.log_report", _data=data)
mock_send_message_to_slack.assert_called_once_with(slack_message)
admin_request.post("reports.log_report", _data=data, _expected_status=201)

mock_log_report.assert_called_once()

0 comments on commit e4afb06

Please sign in to comment.