def test_hydrate_form_to_object_without_mapping(self): form = LoginForm('test') form.data = {'username': '******', 'password': '******'} user = User() form.bind(user, hydrate=False) form.is_valid() assert user.username == 'simon' assert user.password == 'test'
def test_bind_object_to_form_without_mapping(self): form = LoginForm('test') user = User(username='******', password='******') form.bind(user) assert form.username.value == 'simon' assert form.password.value == 'test' form.data = {'password': '******'} assert form.password.value == 'newpass'
def test_bind_object_to_form_with_mapping(self): form = LoginForm('test') user = User(username='******', password='******') user.personal.first_name = 'Simon' user.personal.contact.email = '*****@*****.**' form.bind(user, form_user_mapping) assert form.username.value == 'simon' assert form.first_name.value == 'Simon' assert form.email.value == '*****@*****.**' assert form.password.value == 'test' form.data = {'password': '******'} assert form.password.value == 'newpass'
def test_hydrate_form_to_object_with_mapping(self): form = LoginForm('test') form.data = { 'username': '******', 'password': '******', 'email': '*****@*****.**' } user = User() form.bind(user, form_user_mapping, hydrate=False) form.is_valid() assert user.username == 'simon' assert user.password == 'test' assert user.personal.contact.email == '*****@*****.**'