I want to do unit tests for my Django app.
I'm using the Django-oauth-toolkit
library to protect my views, but I can't test my APIs because they are protected by a Bearer Token.
def test_get_meeting_list(self):
response = self.client.get('/meetings/')
# (I need to pass a token,
# but I won't have the token)
self.assertEqual(response.status_code, 200)
# (AssertionError: 401 != 200)
So, how could I test that?
I tried to make a fake authentication like the official lib tests https://github.com/jazzband/django-oauth-toolkit/blob/master/tests/test_application_views.py but I realized that's will be very complex.