def test_create(self):
     """
     Tests for profile.create
     """
     security.check(self, CREATE_PATH, causes.ssl)
     
     #-------------------------------------------------
     # The person form is displayed
     #-------------------------------------------------
     self.assertState(
         'GET',
         CREATE_PATH,
         [
             causes.ssl,
             causes.owner_logged_in,
             causes.valid_domain,
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.status(200),
         ]
     )
     #-------------------------------------------------
     # If input errors, the person form is displayed
     #-------------------------------------------------
     self.assertState(
         'POST',
         CREATE_PATH,
         [
             causes.ssl,
             causes.owner_logged_in,
             causes.valid_domain,
             causes.invalid_create_person_parameters,
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.form_errors('form'),
             effects.status(200),
         ]
     )
     #-------------------------------------------------
     # Password is required for create.
     #-------------------------------------------------
     self.assertState(
         'POST',
         CREATE_PATH,
         [
             causes.ssl,
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(**create_person_parameters_without_password),
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.form_errors('form'),
             effects.status(200),
         ]
     )
     #-------------------------------------------------
     # If everything is valid, create the person
     #-------------------------------------------------
     self.assertState(
         'POST',
         CREATE_PATH,
         [
             causes.ssl,
             causes.alters(Person),
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(**create_person_parameters),
         ],
         [
             effects.created(Person),
             effects.redirected('/person/list/'),
         ]
     )
 
 
 def test_edit(self):
     security.check(self, EDIT_PATH)
     
     #-------------------------------------------------
     # Show the form
     #-------------------------------------------------
     self.assertState(
         'GET',
         EDIT_PATH,
         [
             causes.owner_logged_in,
             causes.valid_domain,
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.status(200),
         ]
     )
     #-------------------------------------------------
     # If the person does not exist, 404
     #-------------------------------------------------
     self.assertState(
         'GET/POST',
         EDIT_PATH_INVALID,
         [
             causes.owner_logged_in,
             causes.valid_domain,
         ],
         [
             effects.status(404),
         ]
     )
     #-------------------------------------------------
     # If the person does not belong to the account 404
     #-------------------------------------------------
     self.assertState(
         'GET/POST',
         EDIT_PATH_MISMATCH,
         [
             causes.owner_logged_in,
             causes.valid_domain,
         ],
         [
             effects.status(404),
         ]
     )
     #-------------------------------------------------
     # If invalid input, show form
     #-------------------------------------------------
     self.assertState(
         'POST',
         EDIT_PATH,
         [
             causes.owner_logged_in,
             causes.valid_domain,
             causes.invalid_create_person_parameters,
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.form_errors('form'),
             effects.status(200),
         ]
     )
     
     #-------------------------------------------------
     # If valid, save changes
     #-------------------------------------------------
     self.assertState(
         'POST',
         EDIT_PATH,
         [
             causes.alters(Person),
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(
                 username = '******',
                 new_password = '',
                 new_password_confirm = '',
                 first_name = 'bob',
                 last_name = 'jones',
                 email = '*****@*****.**',
             ),
         ],
         [
             effects.field_value(Person, {'pk':1}, first_name = 'bob'),
             effects.person_has_password(1, 'password'),
             effects.redirected('/person/list/'),
         ]
     )
     
     #-------------------------------------------------
     # If valid, save changes
     #-------------------------------------------------
     self.assertState(
         'POST',
         EDIT_PATH,
         [
             causes.alters(Person),
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(
                 username = '******',
                 new_password = '******',
                 new_password_confirm = 'anewpassword',
                 first_name = 'bob',
                 last_name = 'jones',
                 email = '*****@*****.**',
             ),
         ],
         [
             effects.person_has_password(1, 'anewpassword'),
             effects.field_value(Person, {'pk':1}, first_name = 'bob'),
             effects.redirected('/person/list/'),
         ]
     )
     #-------------------------------------------------
     # Edit does not require pasword, does not change
     # if one is not provided.
     #-------------------------------------------------
     self.assertState(
         'POST',
         EDIT_PATH,
         [
             causes.alters(Person),
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(
                 username = '******',
                 new_password = '',
                 new_password_confirm = '',
                 first_name = 'bob',
                 last_name = 'jones',
                 email = '*****@*****.**',
             ),
         ],
         [
             effects.person_has_password(1, 'anewpassword'),
             effects.field_value(Person, {'pk':1}, first_name = 'bob'),
             effects.redirected('/person/list/'),
         ]
     )
     #-------------------------------------------------
     # If passwords didn't match, show form
     #-------------------------------------------------
     self.assertState(
         'POST',
         EDIT_PATH,
         [
             causes.alters(Person),
             causes.owner_logged_in,
             causes.valid_domain,
             causes.params(
                 username = '******',
                 new_password = '******',
                 new_password_confirm = 'does_not_match',
                 first_name = 'bob',
                 last_name = 'jones',
                 email = '*****@*****.**',
             ),
         ],
         [
             effects.rendered('account/person_form.html'),
             effects.context('form', type = forms.BaseForm),
             effects.form_errors('form'),
             effects.status(200),