Re: Trouble Transitioning from SQLite to Postgres

2016-03-04 Thread Mike Dewhirst

On 5/03/2016 7:35 AM, TMC wrote:

I'm new, and I'm having an issue switching to my Django 1.9 database to
Postgres. Having made the switch, all my unit tests pass just fine, and
the site works exactly the way I want it to when I run it locally.
However, my Selenium tests all fail at the login stage. It's odd--if I
follow the steps of the Selenium tests, it works just fine.


Here are the Selenium tests on pastebin
. When I use the sqlite database
(settings ), all these tests pass. When I
set postgres up and switched to it (django settings
, pg_hba.conf
) The
test_whether_login_works_with_django_client test passes. The
test_whether_login_page_works test fails with this traceback
. What happens is that the Selenium
browser sends the login info to the login page, and gets redirected to
the login page.


Here are some things I've ruled out:


This is a shot in the dark but it may be a timing issue. Each new 
version of Django (I think) increases the number of hashes of a password 
to delay login so it becomes expensive for brute force attacks. Can you 
test what the delay is?


Maybe Selenium isn't coping with that?

Don't know what the SQLite vs Postgres difference might be except SQLite 
is possibly a bit faster.


Mike




1) The login credentials are correct. This is checked in two places. The
log_user_in helper function in the Selenium tests tests the credentials
directly using django.contrib.auth.authenticate on line 45 and following
of the Selenium tests . In addition, the
test_whether_login_works_with_django_test_client tests the credentials
directly by sending them to the login view and testing whether the user
is authenticated.


2) Django is able to write to and read from the postgres database. The
unit tests I've set up for this pass, plus I can manually create users,
login, save items, and retrieve items from the database using
manage.py's runserver feature.


3) The problem is not with the login view, at least directly. If I
switch back to the sqlite database, these tests pass just fine.
(I've switched the settings back and forth several times.) Plus, I've
manually tested the login page with my browser.


4) The problem doesn't result from an attempt to migrate data from the
old sqlite database. I just set up the postgres database,
ran makemigrations and migrate, and started with a brand new database.


I'm pretty stumped. I've got Selenium up to date with pip. I'm using
python 3.4. I posted on Stack Overflow, but nobody can figure it out.


Thanks!

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4a6c1395-e50a-4d9d-8b19-51cbdd93965d%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56D9FC24.6050908%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Trouble Transitioning from SQLite to Postgres

2016-03-04 Thread TMC


I'm new, and I'm having an issue switching to my Django 1.9 database to 
Postgres. Having made the switch, all my unit tests pass just fine, and the 
site works exactly the way I want it to when I run it locally. However, my 
Selenium tests all fail at the login stage. It's odd--if I follow the steps 
of the Selenium tests, it works just fine.


Here are the Selenium tests on pastebin . When 
I use the sqlite database (settings ), all 
these tests pass. When I set postgres up and switched to it (django settings 
, pg_hba.conf ) 
The test_whether_login_works_with_django_client test passes. The 
test_whether_login_page_works test fails with this traceback 
. What happens is that the Selenium browser 
sends the login info to the login page, and gets redirected to the login 
page.


Here are some things I've ruled out:


1) The login credentials are correct. This is checked in two places. The 
log_user_in helper function in the Selenium tests tests the credentials 
directly using django.contrib.auth.authenticate on line 45 and following of 
the Selenium tests . In addition, the 
test_whether_login_works_with_django_test_client tests the credentials 
directly by sending them to the login view and testing whether the user is 
authenticated.


2) Django is able to write to and read from the postgres database. The unit 
tests I've set up for this pass, plus I can manually create users, login, 
save items, and retrieve items from the database using manage.py's 
runserver feature.


3) The problem is not with the login view, at least directly. If I switch 
back to the sqlite database, these tests pass just fine. (I've switched the 
settings back and forth several times.) Plus, I've manually tested the 
login page with my browser.


4) The problem doesn't result from an attempt to migrate data from the old 
sqlite database. I just set up the postgres database, ran makemigrations 
and migrate, and started with a brand new database.


I'm pretty stumped. I've got Selenium up to date with pip. I'm using python 
3.4. I posted on Stack Overflow, but nobody can figure it out.


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a6c1395-e50a-4d9d-8b19-51cbdd93965d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.