mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-04-05 05:08:54 +00:00
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:
@@ -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)
|
||||
|
||||
5
tests.py
5
tests.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user