summaryrefslogtreecommitdiff
path: root/src/mailman/model/tests
diff options
context:
space:
mode:
authorBarry Warsaw2016-03-08 23:01:14 -0500
committerBarry Warsaw2016-03-08 23:01:14 -0500
commitcb8ddd1671e424478f002e527871f0c5839425d9 (patch)
treeff8845ca998b2b4ea2f67a908c862d79f664f6d7 /src/mailman/model/tests
parent47b4d1f987a91e1a2ce9b1e533c166ca21c2477e (diff)
downloadmailman-cb8ddd1671e424478f002e527871f0c5839425d9.tar.gz
mailman-cb8ddd1671e424478f002e527871f0c5839425d9.tar.zst
mailman-cb8ddd1671e424478f002e527871f0c5839425d9.zip
Fix cross-posting held on more than one list.
Closes #176 Also: * IMessageStore no longer raises a ValueError if the Message-ID already exists in the store; it just returns None. * The internal handle_message() function no longer takes a `preserve` argument, since messages are never removed from the IMessageStore.
Diffstat (limited to 'src/mailman/model/tests')
-rw-r--r--src/mailman/model/tests/test_messagestore.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mailman/model/tests/test_messagestore.py b/src/mailman/model/tests/test_messagestore.py
index 6e3142536..998fa36c0 100644
--- a/src/mailman/model/tests/test_messagestore.py
+++ b/src/mailman/model/tests/test_messagestore.py
@@ -137,3 +137,22 @@ X-Message-ID-Hash: abc
self.assertEqual(len(x_message_id_hashes), 1)
self.assertEqual(x_message_id_hashes[0],
'MS6QLWERIJLGCRF44J7USBFDELMNT2BW')
+
+ def test_add_message_duplicate_okay(self):
+ msg = mfs("""\
+Subject: Once
+Message-ID: <ant>
+
+""")
+ hash32 = self._store.add(msg)
+ stored_msg = self._store.get_message_by_id('<ant>')
+ self.assertEqual(msg['subject'], stored_msg['subject'])
+ self.assertEqual(msg['message-id-hash'], hash32)
+ # A second insertion, even if headers change, does not store the
+ # message twice.
+ del msg['subject']
+ msg['Subject'] = 'Twice'
+ hash32 = self._store.add(msg)
+ stored_msg = self._store.get_message_by_id('<ant>')
+ self.assertNotEqual(msg['subject'], stored_msg['subject'])
+ self.assertIsNone(hash32)