~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/rest/tests/test_users.py

  • Committer: Barry Warsaw
  • Date: 2015-02-06 03:04:45 UTC
  • Revision ID: barry@list.org-20150206030445-yu808dw9pyzr2exd
 * When creating a user with an email address, do not create the user record
   if the email address already exists.  Given by Andrew Stuart.
   (LP: #1418280)

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
                     })
189
189
        self.assertEqual(cm.exception.code, 404)
190
190
 
 
191
    def test_create_user_twice(self):
 
192
        # LP: #1418280.  No additional users should be created when an address
 
193
        # that already exists is given.
 
194
        content, response = call_api('http://localhost:9001/3.0/users')
 
195
        self.assertEqual(content['total_size'], 0)
 
196
        # Create the user.
 
197
        call_api('http://localhost:9001/3.0/users', dict(
 
198
            email='anne@example.com'))
 
199
        # There is now one user.
 
200
        content, response = call_api('http://localhost:9001/3.0/users')
 
201
        self.assertEqual(content['total_size'], 1)
 
202
        # Trying to create the user with the same address results in an error.
 
203
        with self.assertRaises(HTTPError) as cm:
 
204
            call_api('http://localhost:9001/3.0/users', dict(
 
205
                email='anne@example.com'))
 
206
        self.assertEqual(cm.exception.code, 400)
 
207
        self.assertEqual(cm.exception.reason,
 
208
                         b'Address already exists: anne@example.com')
 
209
        # But at least no new users was created.
 
210
        content, response = call_api('http://localhost:9001/3.0/users')
 
211
        self.assertEqual(content['total_size'], 1)
 
212
 
191
213
 
192
214
 
193
215
class TestLP1074374(unittest.TestCase):