summaryrefslogtreecommitdiff
path: root/src/mailman/rest/tests
diff options
context:
space:
mode:
authorAurélien Bompard2015-07-30 09:37:31 +0200
committerBarry Warsaw2016-05-04 21:05:49 -0500
commitb51e9a92fd042da51db5f7aec9795ff5a00cc847 (patch)
tree6ed50a940b11cffb3d71c2a2ffe94c37baa8b9cb /src/mailman/rest/tests
parent7216f6366ff51b034e420efb1206d1676dce78ef (diff)
downloadmailman-b51e9a92fd042da51db5f7aec9795ff5a00cc847.tar.gz
mailman-b51e9a92fd042da51db5f7aec9795ff5a00cc847.tar.zst
mailman-b51e9a92fd042da51db5f7aec9795ff5a00cc847.zip
Allow merging users from the REST interface
Diffstat (limited to 'src/mailman/rest/tests')
-rw-r--r--src/mailman/rest/tests/test_addresses.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mailman/rest/tests/test_addresses.py b/src/mailman/rest/tests/test_addresses.py
index edcfdfa86..c75641ea9 100644
--- a/src/mailman/rest/tests/test_addresses.py
+++ b/src/mailman/rest/tests/test_addresses.py
@@ -212,6 +212,25 @@ class TestAddresses(unittest.TestCase):
anne_person = user_manager.get_address('anne@example.com')
self.assertEqual(anne_person.display_name, '')
+ def test_existing_address_absorb(self):
+ # Trying to add an existing address causes a merge if the
+ # 'force_existing' flag is present.
+ user_manager = getUtility(IUserManager)
+ with transaction():
+ anne = user_manager.create_user('anne@example.com')
+ bill = user_manager.create_user('bill@example.com')
+ response, content = call_api(
+ 'http://localhost:9001/3.0/users/anne@example.com/addresses', {
+ 'email': 'bill@example.com',
+ 'force_existing': '1',
+ })
+ self.assertIn('bill@example.com',
+ [addr.email for addr in anne.addresses])
+ self.assertEqual(content['status'], '201')
+ self.assertEqual(
+ content['location'],
+ 'http://localhost:9001/3.0/addresses/bill@example.com')
+
def test_invalid_address_bad_request(self):
# Trying to add an invalid address string returns 400.
with transaction():