question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket support (django channels)

See original GitHub issue

Is it possible to configure behave-django to test django apps with channels integrated?

For WSGI there is wsgiref used right in the documentation:

import threading
from wsgiref import simple_server
from selenium import webdriver
from my_application import model
from my_application import web_app

def before_all(context):
    context.server = simple_server.WSGIServer(('', 8000))
    context.server.set_app(web_app.main(environment='test’))
    context.thread = threading.Thread(target=context.server.serve_forever) context.thread.start()
    context.browser = webdriver.Chrome() 

However Django channels is using ASGI and daphne: http://channels.readthedocs.io/en/latest/asgi.html

Currently I’m deploying my app (for debugging) by:

$ venv/bin/daphne <app>.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2
$ venv/bin/python manage.py runworker --settings=<app>.settings -v2

How can I configure behave-django to use daphne (and use runworker…)

I tried to set “context.server” in “before_all”, googled a lot but I still can’t figure it out.

Should I override DjangoBehaveTestSuiteRunner and if so, how?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
iansparkscommented, Apr 23, 2021

Sorry @UrAvgProgrammer but I haven’t looked at Channels since early 2017 when we decided to drop channels and move to a polling solution based on vanilla Django.

1reaction
bittnercommented, Mar 23, 2017

Hello all, @proofit404 has contributed a significant amount of work for a ChannelLiveServerTestCase in https://github.com/django/channels/pull/497. 🥇

Please clone the changes, try the code, and give feedback! As soon as we have confirmed that this works as needed it’s probably going to be merged into django/channel master. Hurry! 🚀 Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Channels and WebSockets - LogRocket Blog
Django Channels facilitates support of WebSockets in Django in a manner similar to traditional HTTP views. It wraps Django's native ...
Read more >
Django Channels — Channels 4.0.0 documentation
Channels is a project that takes Django and extends its abilities beyond HTTP - to handle WebSockets, chat protocols, IoT protocols, and more....
Read more >
Getting Started with Django Channels - Real Python
With WebSockets (via Django Channels) managing the communication between the client and the server, whenever a user is authenticated, an event will be ......
Read more >
A Beginners Guide to WebSockets in Django - Medium
pip install channels==2.1.2 · INSTALLED_APPS = [ 'django. · python manage.py migrate. Now if you guys were to run · python manage.py runserver....
Read more >
Django Websockets: A Complete Beginners Guide! - eSketchers
Websockets using Django Channels ... Django 2.0 or above comes with asynchronous support. It has full support to create WebSockets connections and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found