2026-07-26 09:28:48 +02:00
|
|
|
"""Folder-name special-use heuristics (SPEC §6.3 / §12 M2)."""
|
2026-07-17 23:20:34 +02:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from app.sync.folder_names import infer_special_use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"path,expected",
|
|
|
|
|
[
|
2026-07-26 09:28:48 +02:00
|
|
|
# inbox
|
2026-07-17 23:20:34 +02:00
|
|
|
("INBOX", "inbox"),
|
|
|
|
|
("inbox", "inbox"),
|
2026-07-26 09:28:48 +02:00
|
|
|
("INBOX.", "inbox"), # Dovecot may show a trailing delimiter
|
|
|
|
|
# English / Outlook / Gmail
|
2026-07-17 23:20:34 +02:00
|
|
|
("Sent", "sent"),
|
2026-07-26 09:28:48 +02:00
|
|
|
("Sent Items", "sent"),
|
|
|
|
|
("[Gmail]/Sent Mail", "sent"),
|
2026-07-17 23:20:34 +02:00
|
|
|
("Drafts", "drafts"),
|
2026-07-26 09:28:48 +02:00
|
|
|
("Deleted Items", "trash"),
|
|
|
|
|
("Bin", "trash"),
|
2026-07-17 23:20:34 +02:00
|
|
|
("Junk", "junk"),
|
2026-07-26 09:28:48 +02:00
|
|
|
("Junk E-mail", "junk"), # Outlook, punctuation-insensitive
|
|
|
|
|
("[Gmail]/Spam", "junk"),
|
2026-07-17 23:20:34 +02:00
|
|
|
("Archive", "archive"),
|
2026-07-26 09:28:48 +02:00
|
|
|
("[Gmail]/All Mail", "archive"),
|
|
|
|
|
# Polish (accents)
|
|
|
|
|
("Wysłane", "sent"),
|
|
|
|
|
("Elementy wysłane", "sent"),
|
|
|
|
|
("Robocze", "drafts"),
|
|
|
|
|
("Kosz", "trash"),
|
|
|
|
|
("Wiadomości-śmieci", "junk"),
|
2026-07-17 23:20:34 +02:00
|
|
|
("Archiwum", "archive"),
|
2026-07-26 09:28:48 +02:00
|
|
|
# German
|
|
|
|
|
("Gesendet", "sent"),
|
|
|
|
|
("Gesendete Elemente", "sent"),
|
|
|
|
|
("Entwürfe", "drafts"),
|
|
|
|
|
("Papierkorb", "trash"),
|
|
|
|
|
("Gelöschte Elemente", "trash"),
|
|
|
|
|
# French
|
|
|
|
|
("Éléments envoyés", "sent"),
|
|
|
|
|
("Brouillons", "drafts"),
|
|
|
|
|
("Corbeille", "trash"),
|
|
|
|
|
("Courrier indésirable", "junk"),
|
|
|
|
|
# Spanish / Italian / Dutch / Portuguese
|
|
|
|
|
("Enviados", "sent"),
|
|
|
|
|
("Papelera", "trash"),
|
|
|
|
|
("Posta inviata", "sent"),
|
|
|
|
|
("Cestino", "trash"),
|
|
|
|
|
("Verzonden", "sent"),
|
|
|
|
|
("Prullenbak", "trash"),
|
|
|
|
|
("Itens enviados", "sent"),
|
|
|
|
|
("Lixeira", "trash"),
|
|
|
|
|
# Russian (Cyrillic)
|
|
|
|
|
("Отправленные", "sent"),
|
|
|
|
|
("Корзина", "trash"),
|
|
|
|
|
("Черновики", "drafts"),
|
|
|
|
|
("Спам", "junk"),
|
|
|
|
|
# delimiters / nesting
|
|
|
|
|
("INBOX/Sent", "sent"),
|
|
|
|
|
("INBOX.Sent", "sent"), # Dovecot dot delimiter
|
|
|
|
|
("INBOX.Trash", "trash"),
|
|
|
|
|
# negatives — must not misfire
|
2026-07-17 23:20:34 +02:00
|
|
|
("Work", None),
|
|
|
|
|
("Random Folder", None),
|
2026-07-26 09:28:48 +02:00
|
|
|
("Sent to John", None), # curated names, not substring match
|
|
|
|
|
("Newsletter", None),
|
|
|
|
|
("Projects/Client", None),
|
2026-07-17 23:20:34 +02:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
def test_infer_special_use(path: str, expected: str | None) -> None:
|
|
|
|
|
assert infer_special_use(path) == expected
|