'rest_dispatch rejects requests in a deactivated realm, both /json and api'

def test_send_deactivated_realm(self):

    realm = get_realm('zulip')
    do_deactivate_realm(get_realm('zulip'))
    result = self.client_post('/json/messages', {'type': 'private', 'content': 'Test    message', 'client': 'test    suite', 'to': self.example_email('othello')})
    self.assert_json_error_contains(result, 'Not    logged    in', status_code=401)
    realm.deactivated = False
    realm.save()
    self.login(self.example_email('hamlet'))
    realm.deactivated = True
    realm.save()
    result = self.client_post('/json/messages', {'type': 'private', 'content': 'Test    message', 'client': 'test    suite', 'to': self.example_email('othello')})
    self.assert_json_error_contains(result, 'has    been    deactivated', status_code=400)
    result = self.client_post('/api/v1/messages', {'type': 'private', 'content': 'Test    message', 'client': 'test    suite', 'to': self.example_email('othello')}, **self.api_auth(self.example_email('hamlet')))
    self.assert_json_error_contains(result, 'has    been    deactivated', status_code=401)
