Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions puppy_kit/commands/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,12 @@ def create_incident(title, description, severity, team, assignee, customer_impac
type=click.Choice(["yes", "no"]),
help="Is duplicate flag",
)
@click.option(
"--needs-wrench-bot-check",
default=None,
type=click.Choice(["yes", "no"]),
help="NeedsWrenchBotCheck flag — set to yes to trigger the triage webhook",
)
@click.option("--teams", multiple=True, default=None, help="Team names (repeatable)")
@click.option("--services", multiple=True, default=None, help="Service names (repeatable)")
@click.option(
Expand All @@ -621,6 +627,7 @@ def update_incident(
needs_human_attention,
triage_completed,
is_duplicate,
needs_wrench_bot_check,
teams,
services,
related_incidents,
Expand Down Expand Up @@ -648,6 +655,7 @@ def update_incident(
needs_human_attention,
triage_completed,
is_duplicate,
needs_wrench_bot_check,
teams,
services,
related_incidents,
Expand Down Expand Up @@ -719,6 +727,11 @@ def update_incident(
"type": "dropdown",
"value": is_duplicate.capitalize(),
}
if needs_wrench_bot_check is not None:
field_data["NeedsWrenchBotCheck"] = {
"type": "dropdown",
"value": needs_wrench_bot_check.capitalize(),
}
if teams:
field_data["teams"] = {"type": "autocomplete", "value": list(teams)}
if services:
Expand Down
22 changes: 22 additions & 0 deletions tests/commands/test_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,28 @@ def test_update_incident_assignee(self, mock_client, runner):
assert "muhammad" in result.output
mock_client.incidents.update_incident.assert_called_once()

def test_update_incident_needs_wrench_bot_check(self, mock_client, runner):
"""Test that --needs-wrench-bot-check sets NeedsWrenchBotCheck in field_data."""
inc = _make_incident("inc-1", "Service outage", "SEV-3", "active")
response = Mock(data=inc)
mock_client.incidents.update_incident.return_value = response

mock_cfg = Mock(site="datadoghq.com", api_key="test-api-key", app_key="test-app-key")
with patch("puppy_kit.commands.incident.get_datadog_client", return_value=mock_client):
with patch("puppy_kit.commands.incident.load_config", return_value=mock_cfg):
with patch("puppy_kit.commands.incident.requests.patch") as mock_patch:
mock_patch.return_value = Mock(raise_for_status=Mock())
result = runner.invoke(
incident,
["update", "inc-1", "--needs-wrench-bot-check", "yes"],
)

assert result.exit_code == 0, f"Command failed: {result.output}"
assert "updated" in result.output
_, kwargs = mock_patch.call_args
sent_fields = kwargs["json"]["data"]["attributes"]["fields"]
assert sent_fields["NeedsWrenchBotCheck"] == {"type": "dropdown", "value": "Yes"}


class TestSetStatusIncident:
def test_set_status_table(self, runner):
Expand Down
Loading