mirror of
https://github.com/django/daphne.git
synced 2025-08-04 02:20:08 +03:00
Fixed #748: Test client now handles headers as lists not dict
This commit is contained in:
parent
07053bebcc
commit
32da46f51d
|
@ -82,6 +82,9 @@ class WSClient(Client):
|
|||
self.channel_layer.send(to, self._get_content(content, text, path))
|
||||
self._session_cookie = False
|
||||
|
||||
def _list_headers(self):
|
||||
return [[key.encode(), self.headers[key]] for key in self.headers]
|
||||
|
||||
def _get_content(self, content={}, text=None, path='/'):
|
||||
content = copy.deepcopy(content)
|
||||
content.setdefault('reply_channel', self.reply_channel)
|
||||
|
@ -93,7 +96,7 @@ class WSClient(Client):
|
|||
else:
|
||||
content.setdefault('path', path)
|
||||
|
||||
content.setdefault('headers', self.headers)
|
||||
content.setdefault('headers', self._list_headers())
|
||||
|
||||
if self._ordered:
|
||||
if 'order' in content:
|
||||
|
|
|
@ -52,8 +52,8 @@ class WSClientTests(ChannelTestCase):
|
|||
self.assertEqual(content['path'], '/')
|
||||
|
||||
self.assertTrue('headers' in content)
|
||||
self.assertTrue('cookie' in content['headers'])
|
||||
self.assertTrue(b'sessionid' in content['headers']['cookie'])
|
||||
self.assertIn(b'cookie', [x[0] for x in content['headers']])
|
||||
self.assertIn(b'sessionid', [x[1] for x in content['headers'] if x[0] == b'cookie'][0])
|
||||
|
||||
def test_ordering_in_content(self):
|
||||
client = WSClient(ordered=True)
|
||||
|
|
Loading…
Reference in New Issue
Block a user