forked from Github-Mirrors/canaille
tests: test mail attachments mimetypes
This commit is contained in:
parent
6ac4aadb02
commit
288ad161d3
2 changed files with 9 additions and 1 deletions
|
@ -40,8 +40,10 @@ def logo():
|
|||
|
||||
def type_from_filename(filename):
|
||||
filetype = mimetypes.guess_type(filename)
|
||||
if not filetype or not filetype[0]: # pragma: no cover
|
||||
if not filetype or not filetype[0]:
|
||||
# For some reasons GHA fails to guess webp mimetypes
|
||||
# According to MDN, the default mimetype should be application/octet-stream
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
||||
return "application", "octet-stream"
|
||||
|
||||
maintype, subtype = filetype[0].split("/")
|
||||
|
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
from flask_webtest import TestApp
|
||||
|
||||
from canaille import create_app
|
||||
from canaille.app.mails import type_from_filename
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -224,3 +225,8 @@ def test_default_from_flask_server_name(configuration, user, smtpd, backend):
|
|||
res = res.form.submit(status=200)
|
||||
assert smtpd.messages[0]["X-MailFrom"] == "admin@foobar.tld"
|
||||
assert smtpd.messages[0]["From"] == '"Canaille" <admin@foobar.tld>'
|
||||
|
||||
|
||||
def test_type_from_filename():
|
||||
assert type_from_filename("index.html") == ("text", "html")
|
||||
assert type_from_filename("unknown") == ("application", "octet-stream")
|
||||
|
|
Loading…
Reference in a new issue