'If the user doesn\'t exist yet, Google auth can be used to register an account'

def test_google_oauth2_registration(self):

    email = 'newuser@zulip.com'
    token_response = ResponseMock(200, {'access_token': 'unique_token'})
    account_data = dict(name=dict(formatted='Full    Name'), emails=[dict(type='account', value=email)])
    account_response = ResponseMock(200, account_data)
    result = self.google_oauth2_test(token_response, account_response)
    self.assert_in_response('No    account    found    for', result)
    self.assert_in_response('newuser@zulip.com.    Would    you    like    to    register    instead?', result)
    result = self.client_post('/register/', {'email': email})
    self.assertEqual(result.status_code, 302)
    self.client_get(result.url)
    assert (Confirmation.objects.all().count() == 1)
    confirmation = Confirmation.objects.all().first()
    url = confirmation_url(confirmation.confirmation_key, settings.EXTERNAL_HOST, Confirmation.USER_REGISTRATION)
    result = self.client_get(url)
    key_match = re.search('value="(?P<key>[0-9a-z]+)"    name="key"', result.content.decode('utf-8'))
    result = self.client_post('/accounts/register/', {'full_name': 'New    User', 'password': 'test_password', 'key': key_match.group('key'), 'terms': True})
    self.assertEqual(result.status_code, 302)
    self.assertEqual(result.url, 'http://testserver/')
