############################ # Signup Tests ############################ def test_signup(self): #------------------------------------------------- # If ssl is not on for GET, redirect to ssl page #------------------------------------------------- self.assertState( 'GET', CREATE_PATH % 1, [ causes.no_domain, causes.no_parameters, ], [ effects.redirected(CREATE_PATH % 1, status = 301, ssl = True) ] ) #------------------------------------------------- # If ssl is not on for POST, 403 Forbidden #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, [ causes.no_domain, causes.no_parameters, ], [ effects.status(403) ] ) #------------------------------------------------- # You can't sign up from a domain belonging # to an account. #------------------------------------------------- self.assertState( 'GET/POST', CREATE_PATH % 0, [ causes.ssl, causes.person_not_logged_in, causes.valid_domain, ], [ effects.status(404), ] ) #------------------------------------------------- # Show the signup form #------------------------------------------------- self.assertState( 'GET/POST', CREATE_PATH % 0, [ causes.ssl, causes.no_domain, causes.no_parameters, ], [ effects.rendered('account/signup_form.html'), effects.status(200) ] ) #------------------------------------------------- # If the subscription level is invaid, show 404 #------------------------------------------------- self.assertState( 'GET/POST', CREATE_PATH % 789, # 789 is invalid subscription level [ causes.ssl, causes.no_domain, causes.no_parameters, ], [ effects.status(404) ] ) #------------------------------------------------- # If the subscription level is free, a credit # card is not required. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 0, # 0 is Free Account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), ], [ effects.redirected_to_url( "http://%s/" % domain ), effects.exists( Account, subdomain = signup_params_no_cc['subdomain'], domain = signup_params_no_cc['domain'], ), effects.exists(Person, email = '*****@*****.**'), effects.person_has_role('account_admin', username = '******'), ] ) #------------------------------------------------- # If the subscription level is NOT free, a credit # card IS required. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), ], [ effects.rendered('account/signup_form.html'), effects.does_not_exist(Person, email = '*****@*****.**'), effects.does_not_exist( Account, subdomain = signup_params_no_cc['subdomain'], domain = signup_params_no_cc['domain'], ), effects.status(200) ] ) #------------------------------------------------- # If everything validates, create a person, account # and recurring payment. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), ], [ effects.redirected_to_url( "http://%s/" % domain ), effects.exists( Account, subdomain = signup_params_no_cc['subdomain'], domain = signup_params_no_cc['domain'], ), effects.exists(Person, email = '*****@*****.**'), effects.person_has_role('account_admin', username = '******'), effects.exists(RecurringPayment, name = 'billy bob'), ] ) #------------------------------------------------- # If the gateway returns an unrecognized response, # show a special message & email the administrator. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), payment_response_error ], [ effects.outbox_len(1), effects.rendered('account/payment_create_error.html'), ] ) #------------------------------------------------- # If the gateway does not accept the payment info, # show the form. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), payment_request_error, ],
def test_signup(self): #------------------------------------------------- # If ssl is not on for GET, redirect to ssl page #------------------------------------------------- self.assertState('GET', CREATE_PATH % 1, [ causes.no_domain, causes.no_parameters, ], [effects.redirected(CREATE_PATH % 1, status=301, ssl=True)]) #------------------------------------------------- # If ssl is not on for POST, 403 Forbidden #------------------------------------------------- self.assertState('POST', CREATE_PATH % 1, [ causes.no_domain, causes.no_parameters, ], [effects.status(403)]) #------------------------------------------------- # You can't sign up from a domain belonging # to an account. #------------------------------------------------- self.assertState('GET/POST', CREATE_PATH % 0, [ causes.ssl, causes.person_not_logged_in, causes.valid_domain, ], [ effects.status(404), ]) #------------------------------------------------- # Show the signup form #------------------------------------------------- self.assertState('GET/POST', CREATE_PATH % 0, [ causes.ssl, causes.no_domain, causes.no_parameters, ], [effects.rendered('account/signup_form.html'), effects.status(200)]) #------------------------------------------------- # If the subscription level is invaid, show 404 #------------------------------------------------- self.assertState( 'GET/POST', CREATE_PATH % 789, # 789 is invalid subscription level [ causes.ssl, causes.no_domain, causes.no_parameters, ], [effects.status(404)]) #------------------------------------------------- # If the subscription level is free, a credit # card is not required. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 0, # 0 is Free Account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), ], [ effects.redirected_to_url("http://%s/" % domain), effects.exists( Account, subdomain=signup_params_no_cc['subdomain'], domain=signup_params_no_cc['domain'], ), effects.exists(Person, email='*****@*****.**'), effects.person_has_role('account_admin', username='******'), ]) #------------------------------------------------- # If the subscription level is NOT free, a credit # card IS required. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), ], [ effects.rendered('account/signup_form.html'), effects.does_not_exist(Person, email='*****@*****.**'), effects.does_not_exist( Account, subdomain=signup_params_no_cc['subdomain'], domain=signup_params_no_cc['domain'], ), effects.status(200) ]) #------------------------------------------------- # If everything validates, create a person, account # and recurring payment. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), ], [ effects.redirected_to_url("http://%s/" % domain), effects.exists( Account, subdomain=signup_params_no_cc['subdomain'], domain=signup_params_no_cc['domain'], ), effects.exists(Person, email='*****@*****.**'), effects.person_has_role('account_admin', username='******'), effects.exists(RecurringPayment, name='billy bob'), ]) #------------------------------------------------- # If the gateway returns an unrecognized response, # show a special message & email the administrator. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), payment_response_error ], [ effects.outbox_len(1), effects.rendered('account/payment_create_error.html'), ]) #------------------------------------------------- # If the gateway does not accept the payment info, # show the form. #------------------------------------------------- self.assertState( 'POST', CREATE_PATH % 1, # 1 is Silver (pay) account [ causes.ssl, delete_test_account, causes.no_domain, causes.params(**signup_params_no_cc), causes.params(**cc_params), payment_request_error, ], [ effects.rendered('account/signup_form.html'), effects.status(200) ])
def test_edit_self(self): #------------------------------------------------- # You have to be logged in to edit yourself #------------------------------------------------- self.assertState( 'GET/POST', EDIT_SELF_PATH, [ causes.person_not_logged_in, causes.valid_domain, ], [ effects.redirected('/person/login/', ssl = True), ] ) #------------------------------------------------- # You have to be using an account to edit yourself. #------------------------------------------------- self.assertState( 'GET/POST', EDIT_SELF_PATH, [ causes.invalid_domain, ], [ effects.status(404) ] ) #------------------------------------------------- # Show the form #------------------------------------------------- self.assertState( 'GET', EDIT_SELF_PATH, [ causes.person_logged_in, causes.valid_domain, ], [ effects.rendered('account/person_form.html'), effects.context('form', type = forms.BaseForm), effects.status(200), ] ) #------------------------------------------------- # Submitting invalid data shows the form #------------------------------------------------- self.assertState( 'POST', EDIT_SELF_PATH, [ causes.person_logged_in, causes.valid_domain, causes.params( first_name = 'mary', last_name = 'sue', email = '---', ), ], [ effects.rendered('account/person_form.html'), effects.context('form', type = forms.BaseForm), effects.status(200), ] ) #------------------------------------------------- # Submitting valid data changes the record. # But if you're not an admin, you can't edit your roles. #------------------------------------------------- self.assertState( 'POST', EDIT_SELF_PATH, [ causes.person_logged_in, causes.valid_domain, causes.params( first_name = 'mary', last_name = 'sue', email = '*****@*****.**', role_set = ['1', '13'], ), ], [ effects.person_has_password(1, 'password'), effects.person_does_not_have_role('account_admin', pk=1), effects.person_does_not_have_role('consultant', pk=1), effects.rendered('account/person_form.html'), effects.context('form', type = forms.BaseForm), effects.status(200), ] ) #------------------------------------------------- # Submitting valid data changes the record. # If your're an admin, you CAN edit your roles # with the exception that you CAN NOT remove your # own admin priveledges. #------------------------------------------------- self.assertState( 'POST', EDIT_SELF_PATH, [ causes.owner_logged_in, causes.valid_domain, causes.params( username = "******", first_name = 'mary', last_name = 'sue', email = '*****@*****.**', role_set = ['14'], ), ], [ effects.person_has_password(2, 'password'), effects.person_has_role('janitor', pk=2), effects.person_has_role('account_admin', pk=2), effects.redirected('/person/'), ] ) #------------------------------------------------- # If the user provides a new password, it will be changed #------------------------------------------------- self.assertState( 'POST', EDIT_SELF_PATH, [ causes.person_logged_in, causes.valid_domain, causes.params( username = '******', first_name = 'starr', last_name = 'horne', email = '*****@*****.**', new_password = '******', new_password_confirm = 'newone', ), ], [ effects.person_has_password(1, 'newone'),