summaryrefslogtreecommitdiff
path: root/src/mailman/rules/tests
diff options
context:
space:
mode:
authorAurélien Bompard2015-11-20 09:11:56 +0100
committerBarry Warsaw2016-11-28 20:31:09 -0500
commitb570b76724c6341921ebe531071904df312d39e6 (patch)
treee5faec0fc5a98e6adb0bd4e3288d293891458d18 /src/mailman/rules/tests
parent432088db522219d6caa6c2cfede3df45acb6f3e0 (diff)
downloadmailman-b570b76724c6341921ebe531071904df312d39e6.tar.gz
mailman-b570b76724c6341921ebe531071904df312d39e6.tar.zst
mailman-b570b76724c6341921ebe531071904df312d39e6.zip
Diffstat (limited to 'src/mailman/rules/tests')
-rw-r--r--src/mailman/rules/tests/test_suspicious.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mailman/rules/tests/test_suspicious.py b/src/mailman/rules/tests/test_suspicious.py
new file mode 100644
index 000000000..1be0eb8e7
--- /dev/null
+++ b/src/mailman/rules/tests/test_suspicious.py
@@ -0,0 +1,52 @@
+# Copyright (C) 2015 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/>.
+
+"""Test the `suspicious` rule."""
+
+__all__ = [
+ 'TestSuspicious',
+ ]
+
+
+import os
+import unittest
+from email.header import Header
+
+from mailman.app.lifecycle import create_list
+from mailman.email.message import Message
+from mailman.rules import suspicious
+from mailman.testing.layers import ConfigLayer
+
+
+
+class TestSuspicious(unittest.TestCase):
+ """Test the suspicous rule."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+ self._rule = suspicious.SuspiciousHeader()
+
+ def test_header_instance(self):
+ # Check the case where the subject is a Header instance
+ msg = Message()
+ msg["From"] = Header("user@example.com")
+ self._mlist.bounce_matching_headers = 'from: spam@example.com'
+ result = self._rule.check(self._mlist, msg, {})
+ self.assertFalse(result)
+