I have a project that I started, then decided I should apply a TDD approach.
Well the user registration and login portion already works but I am attempting to add some tests to it.
The user can register, is redirected back to the main page with a Login button.
Here is the test code:
def test_visitor_can_register_and_login_logout(self):
self.browser.get(self.server_url)
self.browser.find_element_by_id('id_register').click()
self.browser.find_element_by_id('id_username').send_keys(TEST_USER)
self.browser.find_element_by_id('id_email').send_keys(TEST_EMAIL)
self.browser.find_element_by_id('id_password1').send_keys(TEST_PASSWORD)
self.browser.find_element_by_id('id_password2').send_keys(TEST_PASSWORD)
self.browser.find_element_by_id('submit_registration').click()
time.sleep(10)
## Existing user is invited to login
self.browser.find_element_by_id('id_login').click()
self.browser.find_element_by_id('id_login').send_keys(TEST_USER)
self.browser.find_element_by_id('id_password').send_keys(TEST_PASSWORD)
self.browser.find_element_by_id('log_me_in').click()
## test user is logged in and can logout
self.browser.find_element_by_id('id_logout').click()
self.browser.find_element_by_tag_name('button').click()
##redirected back to main page
self.browser.find_element_by_id('id_login')
I see the main page load, the registration page loads and the inputs are filled in.
When the submit_registion button is clicked I get a 500. You can see I put a sleep in there just so I could see it and verify that the process isn't running too fast for the server to respond.
I originally had the registration and login in separate tests but I understand that this might require TransactionTestCase ? I am using
from django.test import LiveServerTestCase in this class.
I have one other test before that runs fine.
Any ideas? Tips on troubleshooting this functional test?
============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3Xv1Zz-6uSkUphtNa_kx-YbUbA2MOPn0wOUN-Bpm3sm%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment