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
10 changes: 9 additions & 1 deletion intbot/core/integrations/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def get_repository(self): # pragma: no cover
class GithubProjectV2Item(GithubWebhook):
# NOTE: This might be something for pydantic schemas in the future

def short_action(self):
# "projects_v2_item.edited" -> changed
# "projects_v2_item.created" -> created
action = self.action.split(".")[1]
return {
"edited": "changed",
}.get(action, action)

@property
def sender(self):
sender = self.get_sender()
Expand Down Expand Up @@ -206,7 +214,7 @@ def as_discord_message(self) -> str:
return message(
**{
"sender": self.sender,
"action": self.action,
"action": self.short_action(),
"details": details,
}
)
Expand Down
14 changes: 7 additions & 7 deletions intbot/tests/test_integrations/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_parse_github_webhook_raises_value_error_for_unsupported():

def test_github_project_created_event():
parser = GithubProjectV2Item(
action="created",
action="projects_v2_item.created",
headers={},
content={
"sender": {"login": "testuser", "html_url": "https://github.com/testuser"},
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_github_project_created_event():

def test_github_project_edited_event_for_status_change():
parser = GithubProjectV2Item(
action="changed",
action="projects_v2_item.edited",
headers={},
content={
"sender": {"login": "testuser", "html_url": "https://github.com/testuser"},
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_github_project_edited_event_for_status_change():

def test_github_project_edited_event_for_date_change():
parser = GithubProjectV2Item(
action="edited",
action="projects_v2_item.edited",
headers={},
content={
"sender": {"login": "testuser", "html_url": "https://github.com/testuser"},
Expand Down Expand Up @@ -122,15 +122,15 @@ def test_github_project_edited_event_for_date_change():
message = parser.as_discord_message()

assert message == (
"[@testuser](https://github.com/testuser) edited **Deadline** of "
"[@testuser](https://github.com/testuser) changed **Deadline** of "
"**[Test Issue](https://github.com/test-issue)** "
"from **2024-01-01** to **2025-01-05**"
)


def test_github_project_item_draft_issue_created():
parser = GithubProjectV2Item(
action="created",
action="projects_v2_item.created",
headers={},
content={
"sender": {"login": "testuser", "html_url": "https://github.com/testuser"},
Expand All @@ -153,7 +153,7 @@ def test_github_project_item_draft_issue_created():

def test_github_project_item_edited_event_no_changes():
parser = GithubProjectV2Item(
action="edited",
action="projects_v2_item.edited",
headers={},
content={
"sender": {"login": "testuser", "html_url": "https://github.com/testuser"},
Expand All @@ -173,7 +173,7 @@ def test_github_project_item_edited_event_no_changes():
message = parser.as_discord_message()

assert message == (
"[@testuser](https://github.com/testuser) edited "
"[@testuser](https://github.com/testuser) changed "
"[Test Issue](https://github.com/test-issue)"
)

Expand Down
2 changes: 1 addition & 1 deletion intbot/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_process_github_webhook_creates_a_message_from_supported(
assert dm.content == (
"GitHub: [@github-project-automation[bot]]"
"(https://github.com/apps/github-project-automation)"
" projects_v2_item.edited **Status** of "
" changed **Status** of "
"**[Test Issue](https://github.com/test-issue)**"
" from **Done** to **In progress**"
)
Expand Down