>=== modified file 'lib/lp/registry/stories/foaf/xx-createaccount.txt'
>--- lib/lp/registry/stories/foaf/xx-createaccount.txt 2009-09-11 18:45:31 +0000
>+++ lib/lp/registry/stories/foaf/xx-createaccount.txt 2009-10-07 21:39:02 +0000
>@@ -21,12 +21,34 @@
> The email address you provided isn't valid. Please verify it and try
> again.
>
>-Jane tries again, providing a valid email address and asking to create a new
>-account.
>+Next she enters a valid email address but enters a wrong answer for
>+the incredibly trivial match captcha. She gets an error message.
Did you intend "math captcha" instead of "match captcha"?
> >>> browser.getControl(name='loginpage_email', index=1).value = (
> ... '<email address hidden>')
>- >>> browser.getControl('Register').click()
>+ >>> browser.getControl(name='loginpage_captcha_submission').value = '-1'
>+ >>> browser.getControl('Register').click()
>+ >>> print_feedback_messages(browser.contents)
>+ The answer to the simple math question was incorrect or missing.
>+ Please try again.
>+
>+Jane tries again, providing a the correct captcha answer. Her valid
>+email address from before has been retained in the form.
>+
>+ >>> import re
>+ >>> def get_captcha_answer(contents):
>+ ... expr = re.compile("What is (\d+ .{1} \d+)?")
>+ ... match = expr.search(contents)
>+ ... if match:
>+ ... question = match.group(1)
>+ ... answer = eval(question)
>+ ... return str(answer)
>+ ... return ''
>+
>+ >>> browser.getControl(name='loginpage_captcha_submission').value = (
>+ ... get_captcha_answer(browser.contents))
>+ >>> browser.getControl('Register').click()
>+ >>> print_feedback_messages(browser.contents)
> >>> print extract_text(find_main_content(browser.contents))
> Registration mail sent
> Instructions on completing your registration have been sent to
>@@ -36,7 +58,7 @@
> Launchpad sends Jane an email message containing a token she must use to
> complete the registration process.
>
>- >>> import email, re
>+ >>> import email
> >>> from lp.services.mail import stub
> >>> from canonical.launchpad.ftests.logintoken import (
> ... get_token_url_from_email)
>@@ -91,6 +113,8 @@
> >>> browser.open('http://launchpad.dev/+login')
> >>> browser.getControl(name='loginpage_email', index=1).value = (
> ... '<email address hidden>')
>+ >>> browser.getControl(name='loginpage_captcha_submission').value = (
>+ ... get_captcha_answer(browser.contents))
> >>> browser.getControl('Register').click()
>
> >>> from_addr, to_addrs, raw_msg = stub.test_emails.pop()
>
Hi Brad,
This looks good. I just have one minor comment.
merge-approved
-Edwin
>=== modified file 'lib/lp/ registry/ stories/ foaf/xx- createaccount. txt' registry/ stories/ foaf/xx- createaccount. txt 2009-09-11 18:45:31 +0000 registry/ stories/ foaf/xx- createaccount. txt 2009-10-07 21:39:02 +0000
>--- lib/lp/
>+++ lib/lp/
>@@ -21,12 +21,34 @@
> The email address you provided isn't valid. Please verify it and try
> again.
>
>-Jane tries again, providing a valid email address and asking to create a new
>-account.
>+Next she enters a valid email address but enters a wrong answer for
>+the incredibly trivial match captcha. She gets an error message.
Did you intend "math captcha" instead of "match captcha"?
> >>> browser. getControl( name='loginpage _email' , index=1).value = ( getControl( 'Register' ).click( ) getControl( name='loginpage _captcha_ submission' ).value = '-1' getControl( 'Register' ).click( ) messages( browser. contents) answer( contents) : contents) getControl( name='loginpage _captcha_ submission' ).value = ( answer( browser. contents) ) getControl( 'Register' ).click( ) messages( browser. contents) text(find_ main_content( browser. contents) ) launchpad. ftests. logintoken import ( url_from_ email) launchpad. dev/+login') getControl( name='loginpage _email' , index=1).value = ( getControl( name='loginpage _captcha_ submission' ).value = ( answer( browser. contents) ) getControl( 'Register' ).click( ) emails. pop()
> ... '<email address hidden>')
>- >>> browser.
>+ >>> browser.
>+ >>> browser.
>+ >>> print_feedback_
>+ The answer to the simple math question was incorrect or missing.
>+ Please try again.
>+
>+Jane tries again, providing a the correct captcha answer. Her valid
>+email address from before has been retained in the form.
>+
>+ >>> import re
>+ >>> def get_captcha_
>+ ... expr = re.compile("What is (\d+ .{1} \d+)?")
>+ ... match = expr.search(
>+ ... if match:
>+ ... question = match.group(1)
>+ ... answer = eval(question)
>+ ... return str(answer)
>+ ... return ''
>+
>+ >>> browser.
>+ ... get_captcha_
>+ >>> browser.
>+ >>> print_feedback_
> >>> print extract_
> Registration mail sent
> Instructions on completing your registration have been sent to
>@@ -36,7 +58,7 @@
> Launchpad sends Jane an email message containing a token she must use to
> complete the registration process.
>
>- >>> import email, re
>+ >>> import email
> >>> from lp.services.mail import stub
> >>> from canonical.
> ... get_token_
>@@ -91,6 +113,8 @@
> >>> browser.open('http://
> >>> browser.
> ... '<email address hidden>')
>+ >>> browser.
>+ ... get_captcha_
> >>> browser.
>
> >>> from_addr, to_addrs, raw_msg = stub.test_
>