fix: fix first_name, last_name handling for User form
since those fields are now association proxies in the data model
This commit is contained in:
parent
48f96220b6
commit
6743fc4731
2 changed files with 12 additions and 25 deletions
|
|
@ -202,12 +202,14 @@ class TestUserView(WebTestCase):
|
|||
|
||||
# form can update user password
|
||||
self.assertTrue(auth.check_user_password(barney, "testpass"))
|
||||
self.assertFalse(auth.check_user_password(barney, "testpass2"))
|
||||
form = view.make_model_form(model_instance=barney)
|
||||
form.validated = {"username": "barney", "set_password": "testpass2"}
|
||||
with patch.object(view, "Session", return_value=self.session):
|
||||
user = view.objectify(form)
|
||||
self.assertIs(user, barney)
|
||||
self.assertTrue(auth.check_user_password(barney, "testpass2"))
|
||||
self.assertFalse(auth.check_user_password(barney, "testpass"))
|
||||
|
||||
# form can update user roles
|
||||
form = view.make_model_form(model_instance=barney)
|
||||
|
|
@ -248,10 +250,12 @@ class TestUserView(WebTestCase):
|
|||
# nb. re-attach the person
|
||||
barney.person = self.session.query(model.Person).one()
|
||||
|
||||
# person name is updated
|
||||
self.assertEqual(barney.person.first_name, "Barney")
|
||||
self.assertEqual(barney.person.last_name, "Rubble")
|
||||
# nb. first/last name was blanked out in last edit
|
||||
self.assertEqual(barney.person.first_name, "")
|
||||
self.assertEqual(barney.person.last_name, "")
|
||||
self.assertEqual(barney.person.full_name, "Barney Rubble")
|
||||
|
||||
# person name is updated
|
||||
form = view.make_model_form(model_instance=barney)
|
||||
form.validated = {
|
||||
"username": "barney",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue