'In a realm with `restricted_to_domain = True`, you can\'t invite people
with a different domain from that of the realm or your e-mail address.'

def test_invite_outside_domain_in_closed_realm(self):

    zulip_realm = get_realm('zulip')
    zulip_realm.restricted_to_domain = True
    zulip_realm.save()
    self.login(self.example_email('hamlet'))
    external_address = 'foo@example.com'
    self.assert_json_error(self.invite(external_address, ['Denmark']), "Some    emails    did    not    validate,    so    we    didn't    send    any    invitations.")
