I need some unit tests to check if a user after successful login can open profile editing page, how am I supposed to do this?
I tried this code, but it shows an error. Do I have to use my own view to register a user then to log in or there are some unit test modules for that?
class UserProfilePage(TestCase):
def setUp(self):
self.credentials = {
'username': 'test_user',
'password': 'secret'}
user = User.objects.create_user(**self.credentials)
self.user_profile = {
'user': user,
'first_name': 'Test_1',
'surname': 'test_surname',
'about_me': 'some_info',
'email': 'test@anymail.com',
}
UserProfile.objects.create(**self.user_profile).save()
self.user_id = UserProfile.objects.get(user=user.id)
def test_profile_page_and_current_template(self):
response = self.client.get('/blog/user/profile/', self.user_id)
self.assertEqual(response.status_code, 200)
ValueError: Cannot query "Test_1": Must be "User" instance.