diff options
| author | Aurélien Bompard | 2015-07-30 09:37:31 +0200 |
|---|---|---|
| committer | Barry Warsaw | 2016-05-04 21:05:49 -0500 |
| commit | b51e9a92fd042da51db5f7aec9795ff5a00cc847 (patch) | |
| tree | 6ed50a940b11cffb3d71c2a2ffe94c37baa8b9cb /src/mailman/rest/tests | |
| parent | 7216f6366ff51b034e420efb1206d1676dce78ef (diff) | |
| download | mailman-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.py | 19 |
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(): |
