title: How to write unittests for Consumers in django channels?
body: <p>A'm beginner in <code>django-channels</code>. I'm use <code>channels 2.3.1</code>. I have following code.</p>
  
  <p><strong>main routing</strong></p>
  
  <pre><code>websocket_urlpatterns = [
      url(r'^ws/events/(?P&lt;room_type&gt;[^/]+)/(?P&lt;room_id&gt;[^/]+)/$', consumers.Consumer, name='core-consumer'),
  ]
  </code></pre>
  
  <p><strong>app routing</strong></p>
  
  <pre><code>application = ProtocolTypeRouter({
      'websocket': URLRouter(core.routing.websocket_urlpatterns),
  })
  </code></pre>
  
  <p><strong>consumer</strong></p>
  
  <pre><code>class Consumer(AsyncWebsocketConsumer):
      async def connect(self):
          room_type = self.scope['url_route']['kwargs']['room_type']
          room_id = self.scope['url_route']['kwargs']['room_id']
          self.room_group_name = f'{room_type}_{room_id}'
  
          await self.channel_layer.group_add(self.room_group_name, self.channel_name)
          await self.accept()
  
      async def receive(self, text_data = None, bytes_data = None):
          text_data_json = json.loads(text_data)
          message = text_data_json['message']
  
          await self.channel_layer.group_send(self.room_group_name,
              {'type': 'send_data', 'message': message}
          )
  
      async def disconnect(self, close_code):
          await self.channel_layer.group_discard(self.room_group_name, self.channel_name)
  
      async def send_data(self, event):
          message = event['message']
          await self.send(text_data=json.dumps({
              'data': message
          }))
  
  def send_event(channel='', message=''):
      channel_layer = get_channel_layer()
      asyncio.run(channel_layer.group_send(channel,
          {
              'type': 'send_data',
              'message': message
          }
      ))
  </code></pre>
  
  <p><strong>signal</strong></p>
  
  <pre><code>    def activate_notification(self):
          send_event(f'user_{self.id}',
                     {'message': f"Welcome back to one deeds!"})
  </code></pre>
  
  <p>How can I test every function inside a <code>consumer</code> using <code>unittest</code>?</p>
  
  <p>I read this <a href="https://channels.readthedocs.io/en/latest/topics/testing.html" rel="nofollow noreferrer">documentation</a> but nothing understand(</p>
  
  <p>I want to run test with command <code>./manage.py test</code></p>
  
  <p>I tried testing this with <code>WebsocketCommunicator</code></p>