diff --git a/intbot/core/integrations/github.py b/intbot/core/integrations/github.py index 44db66d..7267f74 100644 --- a/intbot/core/integrations/github.py +++ b/intbot/core/integrations/github.py @@ -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() @@ -206,7 +214,7 @@ def as_discord_message(self) -> str: return message( **{ "sender": self.sender, - "action": self.action, + "action": self.short_action(), "details": details, } ) diff --git a/intbot/tests/test_integrations/test_github.py b/intbot/tests/test_integrations/test_github.py index da65d6f..44cc604 100644 --- a/intbot/tests/test_integrations/test_github.py +++ b/intbot/tests/test_integrations/test_github.py @@ -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"}, @@ -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"}, @@ -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"}, @@ -122,7 +122,7 @@ 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**" ) @@ -130,7 +130,7 @@ def test_github_project_edited_event_for_date_change(): 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"}, @@ -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"}, @@ -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)" ) diff --git a/intbot/tests/test_tasks.py b/intbot/tests/test_tasks.py index abc4a97..9f209ac 100644 --- a/intbot/tests/test_tasks.py +++ b/intbot/tests/test_tasks.py @@ -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**" )