Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write first tests #32

Closed
wants to merge 1 commit into from
Closed

Write first tests #32

wants to merge 1 commit into from

Conversation

ostcar
Copy link

@ostcar ostcar commented Jul 29, 2018

I have a really hard time to write tests for channels2. So I though it might be a good idea to have some example tests.

@andrewgodwin
Copy link
Owner

I agree, though if they're going to go in the examples repo I'd like to see more comments on them :)

@ostcar
Copy link
Author

ostcar commented Jul 31, 2018

You are right. I will add some in the next two weeks (don't have time at before).

Would you also accept a pull request in the channels repo, that would make the user authentication with the WebsocketCommunicator and HTTPCommunicator a bit easier? For example with a new optional attribute 'user' that creates or reuses a session for a user object?

user = User.objects.create(username='user1')
WebsocketCommunicator(application, "/chat/stream/", user=user)

@andrewgodwin
Copy link
Owner

@ostcar I thought there was already something like that on the communicators? I definitely remember there already being an issue/discussion about it before.

@slyapustin
Copy link

@ostcar Here some workaround for that: django/channels#903 (comment)

communicator = WebsocketCommunicator(Consumer, "/")
communicator.scope['user'] = user

@ostcar
Copy link
Author

ostcar commented Feb 21, 2021

Cleaning up my old PRs. If someone else wants to add this code, feal free to copy it and start a new pr

@ostcar ostcar closed this Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants