test: allow mail source folders with spaces
This commit is contained in:
committed by
GitHub
parent
b17c4c309b
commit
2c528137db
@@ -5,6 +5,7 @@ Tests for MailSource model and mail-sources API endpoints.
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
from urllib.parse import parse_qs, urlparse
|
from urllib.parse import parse_qs, urlparse
|
||||||
|
|
||||||
@@ -139,6 +140,17 @@ class TestMailSourceImportModel:
|
|||||||
assert "ignored" not in details[0]
|
assert "ignored" not in details[0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_mail_source_folder_input_has_no_pattern_validation():
|
||||||
|
"""The UI should not reject valid IMAP folder names containing spaces."""
|
||||||
|
template = (Path(__file__).resolve().parents[1] / "templates" / "mail_sources.html").read_text()
|
||||||
|
model_position = template.index('x-model="form.folder"')
|
||||||
|
input_start = template.rfind("<input", 0, model_position)
|
||||||
|
input_end = template.index(">", model_position)
|
||||||
|
folder_input = template[input_start:input_end]
|
||||||
|
|
||||||
|
assert "pattern=" not in folder_input
|
||||||
|
|
||||||
|
|
||||||
class TestImportHistoryDecoding:
|
class TestImportHistoryDecoding:
|
||||||
"""Unit tests for import-history JSON decoding helpers."""
|
"""Unit tests for import-history JSON decoding helpers."""
|
||||||
|
|
||||||
@@ -263,7 +275,7 @@ class TestMailSourcesAPIAuthed:
|
|||||||
"username": "user@example.com",
|
"username": "user@example.com",
|
||||||
"password": "s3cr3t",
|
"password": "s3cr3t",
|
||||||
"use_ssl": True,
|
"use_ssl": True,
|
||||||
"folder": "INBOX",
|
"folder": "Junk Mail",
|
||||||
"polling_interval": 60,
|
"polling_interval": 60,
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
}
|
}
|
||||||
@@ -273,6 +285,7 @@ class TestMailSourcesAPIAuthed:
|
|||||||
assert data["name"] == "My IMAP"
|
assert data["name"] == "My IMAP"
|
||||||
assert data["method"] == "IMAP"
|
assert data["method"] == "IMAP"
|
||||||
assert data["server"] == "imap.example.com"
|
assert data["server"] == "imap.example.com"
|
||||||
|
assert data["folder"] == "Junk Mail"
|
||||||
assert data["password"] == "**redacted**"
|
assert data["password"] == "**redacted**"
|
||||||
assert data["id"] is not None
|
assert data["id"] is not None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user