Fix Gmail delete_message to execute API request (#668)

* Fix Gmail delete to execute request and add regression test

* Fix duplicate GmailConnection import in tests
This commit is contained in:
Kili
2026-03-09 22:11:35 +01:00
committed by GitHub
parent 298d5b6e6e
commit 95e6fb85a1
2 changed files with 2 additions and 5 deletions

View File

@@ -158,7 +158,7 @@ class GmailConnection(MailboxConnection):
return urlsafe_b64decode(msg["raw"]).decode(errors="replace")
def delete_message(self, message_id: str):
self.service.users().messages().delete(userId="me", id=message_id)
self.service.users().messages().delete(userId="me", id=message_id).execute()
def move_message(self, message_id: str, folder_name: str):
label_id = self._find_label_id_for_label(folder_name)

View File

@@ -257,6 +257,7 @@ class TestGmailConnection(unittest.TestCase):
messages_api.modify.assert_called_once()
connection.delete_message("m1")
messages_api.delete.assert_called_once_with(userId="me", id="m1")
messages_api.delete.return_value.execute.assert_called_once()
def testGetCredsFromTokenFile(self):
creds = MagicMock()
@@ -613,8 +614,6 @@ class TestImapConnection(unittest.TestCase):
with self.assertRaises(_BreakLoop):
connection.watch(callback, check_timeout=1)
callback.assert_called_once_with(connection)
class TestGmailAuthModes(unittest.TestCase):
@patch("parsedmarc.mail.gmail.service_account.Credentials.from_service_account_file")
def testGetCredsServiceAccountWithoutSubject(self, mock_from_service_account_file):
@@ -787,7 +786,5 @@ scopes = https://www.googleapis.com/auth/gmail.modify
mock_gmail_connection.call_args.kwargs.get("service_account_user"),
"delegated@example.com",
)
if __name__ == "__main__":
unittest.main(verbosity=2)