Fixed #748: Test client now handles headers as lists not dict

This commit is contained in:
japrogramer 2017-09-27 00:55:14 -05:00 committed by Andrew Godwin
parent 07053bebcc
commit 32da46f51d
2 changed files with 6 additions and 3 deletions

View File

@ -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:

View File

@ -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)