Re: TestCase Client.login() fails

2012-03-28 Thread jondbaker
Thanks for all the responses. I actually solved the problem about 15 minutes after posting this question and indicated so in the first reply. Perhaps that reply did not go out in time? Anyway, thanks for the help! On Wednesday, March 28, 2012 1:28:56 AM UTC-6, rudyryk wrote: > > Hello, Jonathan!

Re: TestCase Client.login() fails

2012-03-28 Thread Reinout van Rees
On 28-03-12 11:17, Alexey Kinyov wrote: Yes: You have to call user.save() after creating it. Otherwise the user > object exists, but it isn't saved to the database yet. That' wrong. Documentation says: create_user(username, email=None, password=None) Creates, saves and returns

Re: TestCase Client.login() fails

2012-03-28 Thread Alexey Kinyov
Hello, Reinout! > Yes: You have to call user.save() after creating it. Otherwise the user > object exists, but it isn't saved to the database yet. That' wrong. Documentation says: create_user(username, email=None, password=None) Creates, saves and returns a User. https://docs.djan

Re: TestCase Client.login() fails

2012-03-28 Thread Alexey Kinyov
Hello, Jonathan! I think issue is in the fragment 'password=user.password' in the line: >         response = self.client.login(username=user.username, > password=user.password) 'user.password' - is not plain text password, it's encrypted and it's not equal 't3stp@s$' ! Alexey rudyryk /// On We

Re: TestCase Client.login() fails

2012-03-28 Thread jondbaker
Problem solved. I forgot that .create_user will create and return a hashed password, which obviously won't work if said returned object password property is entered into the password field of the login form. On Wednesday, March 28, 2012 12:05:49 AM UTC-6, jondbaker wrote: > > I'm trying to write

Re: TestCase Client.login() fails

2012-03-28 Thread Reinout van Rees
On 28-03-12 08:05, jondbaker wrote: def test_login(self): user = User.objects.create_user('test', 't...@test.com', 't3stp@s$') response = self.client.login(username=user.username, password=user.password) self.assertTrue(response) After creating the user, I can verify that user.is_ac

TestCase Client.login() fails

2012-03-27 Thread jondbaker
I'm trying to write a unit test that will verify that the login form authenticates a user. Whenever I run 'manage.py test' the runner fails with this message: *AssertionError: False is not True* *tests.py* from django.test import TestCase from django.test.client import Client from django.contrib