def test_create_person(self, app, db_session, smtplib): """Test the process of creating new persons. """ # get the home page resp = app.get('/person/signin') # click on the 'create new account' link resp = resp.click('Sign up') # fill out the form f = resp.form f['person.email_address'] = '*****@*****.**' f['person.firstname'] = 'Testguy' f['person.lastname'] = 'McTest' f['person.password'] = '******' f['person.password_confirm'] = 'test' f['person.phone'] = '123' f['person.mobile'] = '123' f['person.address1'] = 'here' f['person.city'] = 'there' f['person.postcode'] = '1234' f['person.country'] = 'AUSTRALIA' f['person.i_agree'] = '1' resp = f.submit(extra_environ=dict(REMOTE_ADDR='0.0.0.0')) # did we get an appropriate page? resp = resp.maybe_follow() # Shake out redirects assert "Check your email" in unicode(resp.body, 'utf-8') # check our email assert smtplib.existing is not None message = smtplib.existing # check that it went to the right place assert "*****@*****.**" in message.to_addresses # check that the message has the to address in it to_match = re.match(r'^.*To:.*[email protected].*', message.message, re.DOTALL) assert to_match is not None # check that the message has the user's name name_match = re.match(r'^.*Testguy.*McTest', message.message, re.DOTALL) assert name_match is not None # check that the message was renderered without HTML, i.e. # as a fragment and thus no autohandler crap html_match = re.match(r'^.*<!DOCTYPE', message.message, re.DOTALL) assert html_match is None # check that the message has a url hash in it match = re.match(r'^.*/person/confirm/(\S+)', message.message, re.DOTALL) assert match is not None # visit the url resp = app.get('/person/confirm/%s' % match.group(1)) # check the rego worked reg = Person.find_by_email('*****@*****.**') assert reg is not None assert reg.activated == True # We should be automatically signed in assert isSignedIn(app) # Log out, so we can log in again resp = resp.goto('/person/signout') resp = resp.maybe_follow() assert not isSignedIn(app) # Ensure login works resp = resp.click('Sign in') f = resp.forms['signin-form'] f['person.email_address'] = '*****@*****.**' f['person.password'] = '******' resp = f.submit(extra_environ=dict(REMOTE_ADDR='0.0.0.0')) assert 'details are incorrect' not in resp assert isSignedIn(app)
def test_create_person(self, app, db_session, smtplib): """Test the process of creating new persons. """ # get the home page resp = app.get('/person/signin') # click on the 'create new account' link resp = resp.click('Sign up') # fill out the form f = resp.form f['person.email_address'] = '*****@*****.**' f['person.firstname'] = 'Testguy' f['person.lastname'] = 'McTest' f['person.password'] = '******' f['person.password_confirm'] = 'test' f['person.phone'] = '123' f['person.mobile'] = '123' f['person.address1'] = 'here' f['person.city'] = 'there' f['person.postcode'] = '1234' f['person.country'] = 'AUSTRALIA' f['person.i_agree'] = '1' resp = f.submit(extra_environ=dict(REMOTE_ADDR='0.0.0.0')) # did we get an appropriate page? resp = resp.maybe_follow() # Shake out redirects assert "Check your email" in unicode(resp.body, 'utf-8') # check our email assert smtplib.existing is not None message = smtplib.existing # check that it went to the right place assert "*****@*****.**" in message.to_addresses # check that the message has the to address in it to_match = re.match(r'^.*To:.*[email protected].*', message.message, re.DOTALL) assert to_match is not None # check that the message has the user's name name_match = re.match(r'^.*Testguy.*McTest', message.message, re.DOTALL) assert name_match is not None # check that the message was renderered without HTML, i.e. # as a fragment and thus no autohandler crap html_match = re.match(r'^.*<!DOCTYPE', message.message, re.DOTALL) assert html_match is None # check that the message has a url hash in it match = re.match(r'^.*/person/confirm/(\S+)', message.message, re.DOTALL) assert match is not None # visit the url resp = app.get('/person/confirm/%s' % match.group(1)) # check the rego worked reg = Person.find_by_email('*****@*****.**') assert reg is not None assert reg.activated == True # We should be automatically signed in assert isSignedIn(app) # Log out, so we can log in again resp = resp.goto('/person/signout') resp = resp.maybe_follow() assert not isSignedIn(app) # Ensure login works resp = resp.click('Sign in') f = resp.forms[1] f['person.email_address'] = '*****@*****.**' f['person.password'] = '******' resp = f.submit(extra_environ=dict(REMOTE_ADDR='0.0.0.0')) assert 'details are incorrect' not in resp assert isSignedIn(app)