-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mark_read.py
More file actions
34 lines (26 loc) · 994 Bytes
/
Copy pathtest_mark_read.py
File metadata and controls
34 lines (26 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# test_mark_read.py
from gmail_service import GmailService
import os
def main():
os.chdir(os.path.dirname(__file__)) # ensure working dir is project root
svc = GmailService() # runs auth if needed
# Print the authenticated user's email (sanity)
try:
profile = svc.service.users().getProfile(userId='me').execute()
print("Authenticated as:", profile.get('emailAddress'))
except Exception as e:
print("Could not fetch profile:", e)
emails = svc.get_unread_emails(max_results=1)
print("Fetched unread emails:", emails)
if not emails:
print("No unread emails found (API returned empty list).")
return
mid = emails[0]['id']
before = svc.get_message_labels(mid)
print("Labels BEFORE modify:", before)
ok = svc.mark_as_read(mid)
print("mark_as_read returned:", ok)
after = svc.get_message_labels(mid)
print("Labels AFTER modify:", after)
if __name__ == "__main__":
main()