'Test to add the primary email as alternate.'

@patch('mozillians.common.authbackend.messages.error')
def test_add_primary_email_as_alternate(self, mocked_message):

    user = UserFactory.create(email='foo@example.com')
    request_mock = Mock(spec=HttpRequest)
    request_mock.user = user
    request_mock.user.is_authenticated = Mock()
    request_mock.user.is_authenticated.return_value = True
    self.backend.request = request_mock
    claims = {'email': 'foo@example.com'}
    self.backend.filter_users_by_claims(claims)
    email_q = ExternalAccount.objects.filter(type=ExternalAccount.TYPE_EMAIL, user=user.userprofile, identifier='foo@example.com')
    ok_((not mocked_message.called))
    ok_((not email_q.exists()))
