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)

This commit is contained in:
Frank Pape 2016-08-26 15:04:38 -04:00 committed by Andrew Godwin
parent 39339e66bc
commit c8fdea6460
2 changed files with 10 additions and 3 deletions

View File

@ -129,7 +129,7 @@ class Client(object):
def send_and_consume(self, channel, content={}, fail_on_none=True): 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) self.send(channel, content)
return self.consume(channel, fail_on_none=fail_on_none) return self.consume(channel, fail_on_none=fail_on_none)

View File

@ -10,7 +10,7 @@ from .base import Client
class HttpClient(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 with determined reply channel, auth opportunity, cookies, headers and so on
""" """
@ -61,7 +61,7 @@ class HttpClient(Client):
if content: if content:
return json.loads(content['text']) 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. Send a message to a channel.
Adds reply_channel name and channel_session to the message. Adds reply_channel name and channel_session to the message.
@ -75,6 +75,13 @@ class HttpClient(Client):
content['text'] = json.dumps(text) content['text'] = json.dumps(text)
self.channel_layer.send(to, content) 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): def login(self, **credentials):
""" """
Returns True if login is possible; False if the provided credentials Returns True if login is possible; False if the provided credentials