feat(scouts): add GmailConnector list_labels + stop_watch

This commit is contained in:
Roberto
2026-06-10 15:36:29 +02:00
parent 6e12429f92
commit 78767512f9
2 changed files with 50 additions and 0 deletions

View File

@@ -82,3 +82,27 @@ async def test_archive_calls_trash():
with patch("app.scouts.connectors.gmail._get_gmail_service") as mock_svc:
await conn.archive(scout, ItemRef(source_msg_ref="msg-1"))
mock_svc.return_value.users().messages().trash.assert_called()
@pytest.mark.asyncio
async def test_list_labels_returns_id_and_name():
scout = _make_scout()
conn = GmailConnector()
fake = {"labels": [
{"id": "INBOX", "name": "INBOX", "type": "system"},
{"id": "Label_1", "name": "Work", "type": "user"},
]}
with patch("app.scouts.connectors.gmail._get_gmail_service") as mock_svc:
mock_svc.return_value.users().labels().list().execute.return_value = fake
labels = await conn.list_labels(scout)
assert {"id": "INBOX", "name": "INBOX"} in labels
assert {"id": "Label_1", "name": "Work"} in labels
@pytest.mark.asyncio
async def test_stop_watch_calls_stop():
scout = _make_scout()
conn = GmailConnector()
with patch("app.scouts.connectors.gmail._get_gmail_service") as mock_svc:
await conn.stop_watch(scout)
mock_svc.return_value.users().stop.assert_called()