Arnaud Fouchet
Arnaud Fouchet

Reputation: 953

Django-channels, how to use mocks

I build this chat website, and I'd like to test this functionnality:

Obviously, in my test, I don't want to do the REST call. I'd like to mock the function "push_notif".

But, when I use unittest.patch, the function is not mocked in the consumer (probably because of some async stuff). How can I mock this "push_notif" function

Upvotes: 0

Views: 197

Answers (1)

Arnaud Fouchet
Arnaud Fouchet

Reputation: 953

Out of solution, I made a decorator for my function "push_notif". If in test, it writes in a file "func.__name__,args,kwargs", then I read this file in my test to see if the right call was passed.

Ugly, but getting things done

Upvotes: 1

Related Questions