Skip to content

Commit

Permalink
Merge pull request #12 from loadsmart/supportMessageId
Browse files Browse the repository at this point in the history
Support less seen versions of Message-ID
  • Loading branch information
luizguilhermefr authored Jan 20, 2020
2 parents 8db7a57 + 5fb99c1 commit 41a7489
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gmail_wrapper/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def message_id(self):
While self.id is the user-bound id of the message, self.message_id
is the global id of the message, valid for every user on the thread.
"""
return self.headers.get("Message-ID")
return self.headers.get("Message-ID", self.headers.get("Message-Id"))

@property
def thread_id(self):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ def test_it_archives_a_message(self, mocker, client, raw_complete_message):
raw_complete_message["id"], add_labels=None, remove_labels=["INBOX"]
)

def test_message_id_property(self, client, raw_complete_message):
message = Message(client, raw_complete_message)
assert (
message.message_id
== "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
)
raw_complete_message["payload"]["headers"][3]["name"] = "Message-Id"
assert (
message.message_id
== "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
)
raw_complete_message["payload"]["headers"][3]["name"] = "Invalid"
assert message.message_id is None


class TestAttachment:
def test_it_has_basic_properties_without_additional_fetch(
Expand Down

0 comments on commit 41a7489

Please sign in to comment.