diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/pipeline/scrubber.py | 6 | ||||
| -rw-r--r-- | src/mailman/pipeline/tests/__init__.py | 0 | ||||
| -rw-r--r-- | src/mailman/pipeline/tests/test_scrubber.py | 45 |
3 files changed, 48 insertions, 3 deletions
diff --git a/src/mailman/pipeline/scrubber.py b/src/mailman/pipeline/scrubber.py index 754d81f18..0584c0a2c 100644 --- a/src/mailman/pipeline/scrubber.py +++ b/src/mailman/pipeline/scrubber.py @@ -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> diff --git a/src/mailman/pipeline/tests/__init__.py b/src/mailman/pipeline/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/mailman/pipeline/tests/__init__.py diff --git a/src/mailman/pipeline/tests/test_scrubber.py b/src/mailman/pipeline/tests/test_scrubber.py new file mode 100644 index 000000000..7ac5eb855 --- /dev/null +++ b/src/mailman/pipeline/tests/test_scrubber.py @@ -0,0 +1,45 @@ +# 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') |
