-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from loadsmart/labelSupport
Support labels modification
- Loading branch information
Showing
7 changed files
with
105 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,35 @@ def test_it_returns_an_attachment_body(self, mocker, client, raw_attachment_body | |
mocked_get_raw_attachment_body.assert_called_once_with("CCX457", "123AAB") | ||
assert isinstance(attachment_body, AttachmentBody) | ||
assert attachment_body.id == raw_attachment_body["attachmentId"] | ||
|
||
|
||
class TestModifyRawMessage: | ||
def test_it_modifies_and_return_a_raw_message(self, mocker, raw_complete_message): | ||
mocker.patch( | ||
"gmail_wrapper.client.GmailClient._make_client", | ||
return_value=make_gmail_client(mocker, modify_return=raw_complete_message), | ||
) | ||
client = GmailClient(email="[email protected]", secrets_json_string="{}") | ||
modified_message = client.modify_raw_message( | ||
id="CCX457", add_labels=["processed"], remove_labels=["phishing"] | ||
) | ||
assert modified_message == raw_complete_message | ||
client._messages_resource().modify.assert_called_once_with( | ||
userId="[email protected]", | ||
id="CCX457", | ||
body={"addLabelIds": ["processed"], "removeLabelIds": ["phishing"]}, | ||
) | ||
|
||
|
||
class TestModifyMessage: | ||
def test_it_returns_a_modified_message(self, client, mocker, raw_complete_message): | ||
mocked_modify_raw_message = mocker.patch( | ||
"gmail_wrapper.client.GmailClient.modify_raw_message", | ||
return_value=raw_complete_message, | ||
) | ||
modified_message = client.modify_message( | ||
id="CCX457", add_labels=["foo"], remove_labels=["bar"] | ||
) | ||
mocked_modify_raw_message.assert_called_once_with("CCX457", ["foo"], ["bar"]) | ||
assert isinstance(modified_message, Message) | ||
assert modified_message.id == raw_complete_message["id"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters