I am trying to generate token from from rest_framework.authtoken.models import Token. View is successfully created, but I am writing test for post api using APIClient() from rest_framework.test import APIClient. def test_address_api_auth_token(self):
data = {
"username": self.user.username,
"password": self.user.password
}
self.client.force_authenticate(user=self.user)
response = self.client.post('/api-token-auth/', data, format='json')
self.assertEqual(response.status_code, 200)
Although user and password are created by model. but still I am getting this error -> AssertionError: 400 != 200. Error message -> Invalid usernamen and password .