Commit 5350f487 authored by Barry Warsaw's avatar Barry Warsaw

Fix a typo in guess_extension(), and add a test.

parent f44d4e86
......@@ -66,7 +66,7 @@ log = logging.getLogger('mailman.error')
def guess_extension(ctype, ext):
"""Find the extension mapped to the given content-type.
mimetypes maps multiple extensions to the same type, e.g. .doc, .dot, and
.wiz are all mapped to application/msword. This sucks for finding the
best reverse mapping. If the extension is one of the giving mappings,
......@@ -75,7 +75,7 @@ def guess_extension(ctype, ext):
all_extensions = guess_all_extensions(ctype, strict=False)
if ext in all_extensions:
return ext
return (all_extensions[0] if len(all) > 0 else [])
return (all_extensions[0] if len(all_extensions) > 0 else None)
......@@ -89,7 +89,7 @@ def safe_strftime(fmt, t):
def calculate_attachments_dir(msg, msgdata):
"""Calculate the directory for attachements.
Calculate the directory that attachments for this message will go under.
To avoid inode limitations, the scheme will be:
archives/private/<listname>/attachments/YYYYMMDD/<msgid-hash>/<files>
......
# Copyright (C) 2012 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
"""Scrubber module tests."""
from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
'TestScrubber',
]
import unittest
from mailman.pipeline import scrubber
class TestScrubber(unittest.TestCase):
"""Scrubber module tests."""
def test_guess_extension(self):
# A known extension should be found.
extension = scrubber.guess_extension('application/msword', '.doc')
self.assertEqual(extension, '.doc')
def test_guess_missing_extension(self):
# Maybe some other extension is better.
extension = scrubber.guess_extension('application/msword', '.xxx')
self.assertEqual(extension, '.doc')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment