Skip to content

Commit

Permalink
Add updating the spreadsheet, incident document to closed when clicki…
Browse files Browse the repository at this point in the history
…ng Yes on stale incident notificaiton (#366)

* Adding the close command to be replicated when a someone archives a channel from the stale message notification

* Updating unit tests

* Changing the body passed to the closed incident function to be different than the sentinel one
  • Loading branch information
sylviamclaughlin authored Jan 18, 2024
1 parent ff0227d commit 4ac2b57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
9 changes: 8 additions & 1 deletion app/commands/helpers/incident_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ def archive_channel_action(client, body, ack):
)
log_to_sentinel("incident_channel_archive_delayed", body)
elif action == "archive":
client.conversations_archive(channel=channel_id)
# get the current chanel id and name and make up the body with those 2 values
channel_info = {
"channel_id": channel_id,
"channel_name": body["channel"]["name"],
}
# Call the close_incident function to update the incident document to closed, update the spreadsheet and archive the channel
close_incident(client, channel_info, ack)
# log the event to sentinel
log_to_sentinel("incident_channel_archived", body)


Expand Down
17 changes: 13 additions & 4 deletions app/tests/commands/helpers/test_incident_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,28 @@ def test_archive_channel_action_ignore(mock_log_to_sentinel):
)


@patch("commands.helpers.incident_helper.google_drive.close_incident_document")
@patch(
"commands.helpers.incident_helper.google_drive.update_spreadsheet_close_incident"
)
@patch(
"commands.helpers.incident_helper.extract_google_doc_id",
return_value="dummy_document_id",
)
@patch("commands.helpers.incident_helper.log_to_sentinel")
def test_archive_channel_action_archive(mock_log_to_sentinel):
def test_archive_channel_action_archive(
mock_log_to_sentinel, mock_extract_id, mock_update_spreadsheet, mock_close_document
):
client = MagicMock()
body = {
"actions": [{"value": "archive"}],
"channel": {"id": "channel_id"},
"channel": {"id": "channel_id", "name": "incident-2024-01-12-test"},
"message_ts": "message_ts",
"user": {"id": "user_id"},
}
ack = MagicMock()
incident_helper.archive_channel_action(client, body, ack)
ack.assert_called_once()
client.conversations_archive(channel="channel_id")
assert ack.call_count == 2
mock_log_to_sentinel.assert_called_once_with("incident_channel_archived", body)


Expand Down

0 comments on commit 4ac2b57

Please sign in to comment.