'Signing up with the special accounts_home_with_realm_str endpoint should
fail (i.e. redirect to the standard accounts_home) if
settings.REALMS_HAVE_SUBDOMAINS is true, or if the realm is not
completely open.'

def test_failed_signup_with_realm_str(self):

    realm = get_realm('zulip')
    realm.restricted_to_domain = False
    realm.invite_required = False
    realm.save()
    with self.settings(REALMS_HAVE_SUBDOMAINS=True):
        email = 'user1@acme.com'
        result = self.client_post('/register/zulip/', {'email': email})
        self.assertEqual(result.status_code, 302)
        self.assertIn('accounts/home', result['Location'])
    realm = get_realm('zulip')
    realm.invite_required = True
    realm.save()
    with self.settings(REALMS_HAVE_SUBDOMAINS=False):
        email = 'user1@acme.com'
        result = self.client_post('/register/zulip/', {'email': email})
        self.assertEqual(result.status_code, 302)
        self.assertIn('accounts/home', result['Location'])
