'Tests that when channel capacity is hit when processing due messages,
message is requeued instead of dropped'

def test_channel_full(self):

    for i in range(10):
        Channel(u'asgi.delay').send({u'channel': u'test', u'delay': 1000, u'content': {u'test': u'value'}}, immediately=True)
    worker = PatchedWorker(channel_layers[DEFAULT_CHANNEL_LAYER])
    worker.termed = 10
    worker.run()
    for i in range(1):
        Channel(u'asgi.delay').send({u'channel': u'test', u'delay': 1000, u'content': {u'test': u'value'}}, immediately=True)
    worker = PatchedWorker(channel_layers[DEFAULT_CHANNEL_LAYER])
    worker.termed = 1
    worker.run()
    self.assertEqual(DelayedMessage.objects.count(), 11)
    with mock.patch(u'django.utils.timezone.now', return_value=(timezone.now() + timedelta(milliseconds=2000))):
        worker.termed = 1
        worker.run()
    self.assertEqual(DelayedMessage.objects.count(), 1)
