mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 04:43:58 +00:00
tornado: Add support for testing with subdomains.
This commit is contained in:
@@ -116,7 +116,7 @@ class ZulipTestCase(TestCase):
|
|||||||
kwargs["HTTP_HOST"] = "%s.%s" % (kwargs["subdomain"], settings.EXTERNAL_HOST)
|
kwargs["HTTP_HOST"] = "%s.%s" % (kwargs["subdomain"], settings.EXTERNAL_HOST)
|
||||||
else:
|
else:
|
||||||
kwargs["HTTP_HOST"] = settings.EXTERNAL_HOST
|
kwargs["HTTP_HOST"] = settings.EXTERNAL_HOST
|
||||||
del kwargs["subdomain"]
|
del kwargs['subdomain']
|
||||||
elif 'HTTP_HOST' not in kwargs:
|
elif 'HTTP_HOST' not in kwargs:
|
||||||
kwargs["HTTP_HOST"] = "zulip.%s" % (settings.EXTERNAL_HOST,)
|
kwargs["HTTP_HOST"] = "zulip.%s" % (settings.EXTERNAL_HOST,)
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,19 @@ class TornadoWebTestCase(AsyncHTTPTestCase, ZulipTestCase):
|
|||||||
def client_get(self, path, **kwargs):
|
def client_get(self, path, **kwargs):
|
||||||
# type: (Text, **Any) -> HTTPResponse
|
# type: (Text, **Any) -> HTTPResponse
|
||||||
self.add_session_cookie(kwargs)
|
self.add_session_cookie(kwargs)
|
||||||
|
self.set_http_host(kwargs)
|
||||||
|
if 'HTTP_HOST' in kwargs:
|
||||||
|
kwargs['headers']['Host'] = kwargs['HTTP_HOST']
|
||||||
|
del kwargs['HTTP_HOST']
|
||||||
return self.fetch(path, method='GET', **kwargs)
|
return self.fetch(path, method='GET', **kwargs)
|
||||||
|
|
||||||
def fetch_async(self, method, path, **kwargs):
|
def fetch_async(self, method, path, **kwargs):
|
||||||
# type: (Text, Text, **Any) -> None
|
# type: (Text, Text, **Any) -> None
|
||||||
self.add_session_cookie(kwargs)
|
self.add_session_cookie(kwargs)
|
||||||
|
self.set_http_host(kwargs)
|
||||||
|
if 'HTTP_HOST' in kwargs:
|
||||||
|
kwargs['headers']['Host'] = kwargs['HTTP_HOST']
|
||||||
|
del kwargs['HTTP_HOST']
|
||||||
self.http_client.fetch(
|
self.http_client.fetch(
|
||||||
self.get_url(path),
|
self.get_url(path),
|
||||||
self.stop,
|
self.stop,
|
||||||
@@ -74,6 +82,7 @@ class TornadoWebTestCase(AsyncHTTPTestCase, ZulipTestCase):
|
|||||||
|
|
||||||
def client_get_async(self, path, **kwargs):
|
def client_get_async(self, path, **kwargs):
|
||||||
# type: (Text, **Any) -> None
|
# type: (Text, **Any) -> None
|
||||||
|
self.set_http_host(kwargs)
|
||||||
self.fetch_async('GET', path, **kwargs)
|
self.fetch_async('GET', path, **kwargs)
|
||||||
|
|
||||||
def login(self, *args, **kwargs):
|
def login(self, *args, **kwargs):
|
||||||
@@ -98,7 +107,7 @@ class TornadoWebTestCase(AsyncHTTPTestCase, ZulipTestCase):
|
|||||||
|
|
||||||
def create_queue(self, **kwargs):
|
def create_queue(self, **kwargs):
|
||||||
# type: (**Any) -> str
|
# type: (**Any) -> str
|
||||||
response = self.client_get('/json/events?dont_block=true')
|
response = self.client_get('/json/events?dont_block=true', subdomain="zulip")
|
||||||
self.assertEqual(response.code, 200)
|
self.assertEqual(response.code, 200)
|
||||||
body = ujson.loads(response.body)
|
body = ujson.loads(response.body)
|
||||||
self.assertEqual(body['events'], [])
|
self.assertEqual(body['events'], [])
|
||||||
|
|||||||
Reference in New Issue
Block a user