From 8827063bf2bbdb28c3147f5782a0c3cf7fdb9d1e Mon Sep 17 00:00:00 2001 From: Krukov D Date: Thu, 19 May 2016 22:19:39 +0300 Subject: [PATCH] Remove inherited methods and relative imports (#163) * Remove inherited methods from HttpClient * Using relative import in base of tests --- channels/tests/base.py | 8 ++++---- channels/tests/http.py | 44 ------------------------------------------ 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/channels/tests/base.py b/channels/tests/base.py index dff1e97..a6a3145 100644 --- a/channels/tests/base.py +++ b/channels/tests/base.py @@ -4,10 +4,10 @@ import string from functools import wraps from django.test.testcases import TestCase -from channels import DEFAULT_CHANNEL_LAYER -from channels.routing import Router, include -from channels.asgi import channel_layers, ChannelLayerWrapper -from channels.message import Message +from .. import DEFAULT_CHANNEL_LAYER +from ..routing import Router, include +from ..asgi import channel_layers, ChannelLayerWrapper +from ..message import Message from asgiref.inmemory import ChannelLayer as InMemoryChannelLayer diff --git a/channels/tests/http.py b/channels/tests/http.py index fa44dfd..4dd3840 100644 --- a/channels/tests/http.py +++ b/channels/tests/http.py @@ -4,9 +4,6 @@ import copy from django.apps import apps from django.conf import settings - -from ..asgi import channel_layers -from ..message import Message from ..sessions import session_for_reply_channel from .base import Client @@ -59,23 +56,6 @@ class HttpClient(Client): self._session = session_for_reply_channel(self.reply_channel) return self._session - @property - def channel_layer(self): - """Channel layer as lazy property""" - return channel_layers[self.alias] - - def get_next_message(self, channel): - """ - Gets the next message that was sent to the channel during the test, - or None if no message is available. - - If require is true, will fail the test if no message is received. - """ - recv_channel, content = channel_layers[self.alias].receive_many([channel]) - if recv_channel is None: - return - return Message(content, recv_channel, channel_layers[self.alias]) - def send(self, to, content={}): """ Send a message to a channel. @@ -87,30 +67,6 @@ class HttpClient(Client): content.setdefault('headers', self.headers) self.channel_layer.send(to, content) - def consume(self, channel): - """ - Get next message for channel name and run appointed consumer - """ - message = self.get_next_message(channel) - if message: - consumer, kwargs = self.channel_layer.router.match(message) - return consumer(message, **kwargs) - - def send_and_consume(self, channel, content={}): - """ - Reproduce full live cycle of the message - """ - self.send(channel, content) - return self.consume(channel) - - def receive(self): - """ - Get content of next message for reply channel if message exists - """ - message = self.get_next_message(self.reply_channel) - if message: - return message.content - def login(self, **credentials): """ Returns True if login is possible; False if the provided credentials