'If you invite a mix of already existing and new users, invitations are
only sent to the new users.'

def test_invite_some_existing_some_new(self):

    self.login(self.example_email('hamlet'))
    existing = [self.example_email('hamlet'), u'othello@zulip.com']
    new = [u'foo-test@zulip.com', u'bar-test@zulip.com']
    result = self.client_post('/json/invites', {'invitee_emails': '\n'.join((existing + new)), 'stream': ['Denmark'], 'custom_body': ''})
    self.assert_json_error(result, "Some    of    those    addresses    are    already    using    Zulip,    so    we    didn't    send    them    an    invitation.    We    did    send    invitations    to    everyone    else!")
    for email in existing:
        self.assertRaises(PreregistrationUser.DoesNotExist, (lambda : PreregistrationUser.objects.get(email=email)))
    for email in new:
        self.assertTrue(PreregistrationUser.objects.get(email=email))
    self.check_sent_emails(new)
    prereg_user = get_prereg_user_by_email('foo-test@zulip.com')
    self.assertEqual(prereg_user.email, 'foo-test@zulip.com')
