How to use Django test self.client.get to get user detail with url like this /user/<int:user_id>?
I want to create a test to check if getting user detail run correctly if I go to this url /user/int:user_id. My code is like this:
def test_get_user_detail(self):
self.client.login(username='tes', password='pandora_key')
User_ID = 13
self.db_login = create_user(User_ID)
db_login_count = DB_Login.objects.all().count()
self.assertEqual(db_login_count, 1)
self.assertNotEqual(db_login_count, 0)
db_login_user = DB_Login.objects.filter(User_ID=User_ID).first()
self.assertEqual(db_login_user.User_ID, User_ID)
response = self.client.get('/user/<int:user_id>/', args=[User_ID])
self.assertEqual(response.status_code, 200)
I've check that creating the user with that specific ID work correctly, but when getting that user from the URL the response always get code 404 not found. Anyone knows how to fix this?