def test_user_cant_login_with_invalid_username(self):
get_user_model().objects.create_user('test', email='test', password='test')
client = APIClient()
response = client.post(reverse('auth-login'), {'username': 'invalid', 'password': 'test'})
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
data = json.loads(response.content.decode('utf-8'))
self.assertEqual(data, {u'detail': u'Invalid email or password. Please try logging in again.'})
评论列表
文章目录