Skip to content

Commit

Permalink
docs: instantiate consumers before passing to communicators (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBroach committed Aug 8, 2021
1 parent d1eead4 commit 76a3e7a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/topics/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ order to provide the appropriate async context::

class MyTests(TestCase):
async def test_my_consumer(self):
communicator = HttpCommunicator(MyConsumer, "GET", "/test/")
communicator = HttpCommunicator(MyConsumer.as_asgi(), "GET", "/test/")
response = await communicator.get_response()
self.assertEqual(response["body"], b"test response")
self.assertEqual(response["status"], 200)
Expand All @@ -52,7 +52,7 @@ native ``pytest`` style:
@pytest.mark.asyncio
async def test_my_consumer():
communicator = HttpCommunicator(MyConsumer, "GET", "/test/")
communicator = HttpCommunicator(MyConsumer.as_asgi(), "GET", "/test/")
response = await communicator.get_response()
assert response["body"] == b"test response"
assert response["status"] == 200
Expand Down Expand Up @@ -80,7 +80,7 @@ To construct it, pass it an application and a scope:
.. code-block:: python
from channels.testing import ApplicationCommunicator
communicator = ApplicationCommunicator(MyConsumer, {"type": "http", ...})
communicator = ApplicationCommunicator(MyConsumer.as_asgi(), {"type": "http", ...})
send_input
~~~~~~~~~~
Expand Down Expand Up @@ -163,7 +163,7 @@ options:
.. code-block:: python
from channels.testing import HttpCommunicator
communicator = HttpCommunicator(MyHttpConsumer, "GET", "/test/")
communicator = HttpCommunicator(MyHttpConsumer.as_asgi(), "GET", "/test/")
And then wait for its response:

Expand Down

0 comments on commit 76a3e7a

Please sign in to comment.