'Test that the ``SignupForm`` checks for unique usernames and unique
e-mail addresses.'

def test_signup_form(self):

    invalid_data_dicts = [{u'data': {u'username': u'foo@bar', u'email': u'foo@example.com', u'password': u'foo', u'password2': u'foo', u'tos': u'on'}, u'error': (u'username', [_(u'Username    must    contain    only    letters,    numbers,    dots    and    underscores.')])}, {u'data': {u'username': u'katy-', u'email': u'katy@newexample.com', u'password1': u'foo', u'password2': u'foo2', u'tos': u'on'}, u'error': (u'__all__', [_(u"The    two    password    fields    didn't    match.")])}, {u'data': {u'username': u'john', u'email': u'john@newexample.com', u'password1': u'foo', u'password2': u'foo', u'tos': u'on'}, u'error': (u'username', [_(u'This    username    is    already    taken.')])}, {u'data': {u'username': u'SignUp', u'email': u'foo@example.com', u'password': u'foo', u'password2': u'foo2', u'tos': u'on'}, u'error': (u'username', [_(u'This    username    is    not    allowed.')])}, {u'data': {u'username': u'alice', u'email': u'john@example.com', u'password': u'foo', u'password2': u'foo', u'tos': u'on'}, u'error': (u'email', [_(u'This    email    is    already    in    use.    Please    supply    a    different    email.')])}]
    with override(u'en'):
        for invalid_dict in invalid_data_dicts:
            form = forms.SignupForm(data=invalid_dict[u'data'])
            self.assertFalse(form.is_valid())
            self.assertEqual(form.errors[invalid_dict[u'error'][0]], invalid_dict[u'error'][1])
    form = forms.SignupForm(data={u'username': u'foo.bla', u'email': u'foo@example.com', u'password1': u'foo', u'password2': u'foo', u'tos': u'on'})
    self.assertTrue(form.is_valid())
