4356 |
4356 |
assert not 'Check values then click submit.' in resp.body
|
4357 |
4357 |
assert resp.form['f0'].value == 'foo@localhost'
|
4358 |
4358 |
|
|
4359 |
def test_form_page_profile_verified_radio_item_prefill(pub):
|
|
4360 |
user = create_user(pub)
|
|
4361 |
formdef = create_formdef()
|
|
4362 |
formdef.data_class().wipe()
|
|
4363 |
formdef.fields = [fields.ItemField(id='0', label='item', type='item',
|
|
4364 |
items=['bar@localhost', 'foo@localhost', 'baz@localhost'],
|
|
4365 |
show_as_radio=True,
|
|
4366 |
prefill={'type': 'user', 'value': 'email'})]
|
|
4367 |
formdef.store()
|
|
4368 |
|
|
4369 |
resp = get_app(pub).get('/test/')
|
|
4370 |
assert resp.form['f0'].value is None
|
|
4371 |
|
|
4372 |
user.verified_fields = ['email']
|
|
4373 |
user.store()
|
|
4374 |
|
|
4375 |
resp = login(get_app(pub), username='foo', password='foo').get('/test/')
|
|
4376 |
assert resp.form['f0'].value == 'foo@localhost'
|
|
4377 |
assert 'readonly' in resp.form['f0'].attrs
|
|
4378 |
for radio in resp.html.findAll('input'):
|
|
4379 |
if radio['name'] == 'f0':
|
|
4380 |
if radio['value'] == 'foo@localhost':
|
|
4381 |
assert radio.attrs.get('checked')
|
|
4382 |
assert radio.attrs.get('readonly')
|
|
4383 |
assert not radio.attrs.get('disabled')
|
|
4384 |
else:
|
|
4385 |
assert not radio.attrs.get('checked')
|
|
4386 |
assert radio.attrs.get('readonly')
|
|
4387 |
assert radio.attrs.get('disabled')
|
|
4388 |
|
|
4389 |
resp.form['f0'].value = 'baz@localhost' # try changing the value
|
|
4390 |
resp = resp.form.submit('submit')
|
|
4391 |
assert 'Check values then click submit.' in resp.body
|
|
4392 |
assert resp.form['f0'].value == 'foo@localhost' # it is reverted
|
|
4393 |
|
4359 |
4394 |
def test_item_field_with_disabled_items(http_requests, pub):
|
4360 |
4395 |
user = create_user(pub)
|
4361 |
4396 |
formdef = create_formdef()
|