mardi 26 juillet 2016

Django Redirect Status Code Error

I'm testing a Django app. When the user logs in, I redirect him to a graphs page. To test, I write

response = TestCase.client.post('app/login', {credentials}, follow=True)
TestCase.assertRedirects(response, 'app/graphs')

which returns

AssertionError: False is not true : 
Response didn't redirect as expected: Response code was 200 (expected 302).


Reasonable enough. The docs say assertRedirects has a status_code parameter. Then calling

TestCase.assertRedirects(response, 'app/graphs', status_code=200)

returns

AssertionError: False is not true : 
Response didn't redirect as expected: Response code was 200 (expected 200).

What's going on?

Aucun commentaire:

Enregistrer un commentaire