From c8fdea646075a55da16b2cba897e7b945b16bac3 Mon Sep 17 00:00:00 2001 From: Frank Pape Date: Fri, 26 Aug 2016 15:04:38 -0400 Subject: [PATCH] Add send_and_consume method to HttpClient to match base Client behavior. Change argument ordering in send method to match base client. Fix repeated "live cycle" error in docstrings. (#320) --- channels/tests/base.py | 2 +- channels/tests/http.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/channels/tests/base.py b/channels/tests/base.py index 5a90eca..1f628ac 100644 --- a/channels/tests/base.py +++ b/channels/tests/base.py @@ -129,7 +129,7 @@ class Client(object): def send_and_consume(self, channel, content={}, fail_on_none=True): """ - Reproduce full live cycle of the message + Reproduce full life cycle of the message """ self.send(channel, content) return self.consume(channel, fail_on_none=fail_on_none) diff --git a/channels/tests/http.py b/channels/tests/http.py index ecb0ed3..2b8ecd0 100644 --- a/channels/tests/http.py +++ b/channels/tests/http.py @@ -10,7 +10,7 @@ from .base import Client class HttpClient(Client): """ - Channel http/ws client abstraction that provides easy methods for testing full live cycle of message in channels + Channel http/ws client abstraction that provides easy methods for testing full life cycle of message in channels with determined reply channel, auth opportunity, cookies, headers and so on """ @@ -61,7 +61,7 @@ class HttpClient(Client): if content: return json.loads(content['text']) - def send(self, to, text=None, content={}, path='/'): + def send(self, to, content={}, text=None, path='/'): """ Send a message to a channel. Adds reply_channel name and channel_session to the message. @@ -75,6 +75,13 @@ class HttpClient(Client): content['text'] = json.dumps(text) self.channel_layer.send(to, content) + def send_and_consume(self, channel, content={}, text=None, path='/', fail_on_none=True): + """ + Reproduce full life cycle of the message + """ + self.send(channel, content, text, path) + return self.consume(channel, fail_on_none=fail_on_none) + def login(self, **credentials): """ Returns True if login is possible; False if the provided credentials