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
1 change: 1 addition & 0 deletions scripts/bitbucket_onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"pr:reviewer:needs_work",
"pr:reviewer:updated",
"pr:merged",
"pr:declined",
"pr:deleted",
"repo:refs_changed",
)
Expand Down
42 changes: 42 additions & 0 deletions tests/fixtures/bitbucket_pr_declined.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"eventKey": "pr:declined",
"date": "2026-04-28T10:00:00+0000",
"actor": {
"name": "alice",
"displayName": "Alice Example",
"slug": "alice"
},
"pullRequest": {
"id": 42,
"title": "ABC-123: Add payment retry",
"description": "Fixes ABC-123 and PROJ-9",
"state": "DECLINED",
"closed": true,
"closedDate": 1777370400000,
"fromRef": {
"id": "refs/heads/feature/ABC-123-retries",
"displayId": "feature/ABC-123-retries",
"latestCommit": "abc1234567890abc1234567890abc1234567890a",
"repository": {
"slug": "payments-api",
"project": {"key": "ACME"}
}
},
"toRef": {
"id": "refs/heads/master",
"displayId": "master",
"latestCommit": "0000000000000000000000000000000000000000",
"repository": {
"slug": "payments-api",
"project": {"key": "ACME"}
}
},
"author": {
"user": {
"name": "alice",
"displayName": "Alice Example",
"slug": "alice"
}
}
}
}
31 changes: 31 additions & 0 deletions tests/test_parsers_bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ def test_revert_pr_title_marks_is_revert(self) -> None:
assert result.is_revert is True


class TestExtractPrDeclined:
def test_pr_declined_fixture_returns_draft_with_lowercased_join_keys(self) -> None:
# Given
body = _load("bitbucket_pr_declined.json")

# When
result = extract_event(
body,
x_event_key="pr:declined",
x_request_uuid="req-decl",
x_hook_uuid=None,
)

# Then — declined-PRs share the merged payload shape; the parser
# must persist them with full join keys so they show up in
# downstream rollups (e.g. noergler outcome='declined' joins).
assert isinstance(result, BitbucketEventDraft)
assert result.delivery_id == "req-decl"
assert result.event_type == "pr:declined"
assert result.repo_full_name == "acme/payments-api"
assert result.pr_id == 42
assert result.commit_sha == "abc1234567890abc1234567890abc1234567890a"
assert result.branch_name == "feature/abc-123-retries"
assert result.author == "alice"
assert result.is_revert is False
assert result.change_type == "feature"
assert "ABC-123" in result.jira_keys
assert "PROJ-9" in result.jira_keys
assert result.payload is body


class TestExtractRefsChanged:
def test_branch_push_extracts_to_hash_and_branch(self) -> None:
# Given
Expand Down