0001-tests-check-post-condition-using-getlist-on-block-47.patch
tests/form_pages/test_block.py | ||
---|---|---|
834 | 834 |
{'123': 'foo2', '234': '2', '234_display': 'deux'}, |
835 | 835 |
] |
836 | 836 |
assert formdef.data_class().select()[0].data['1_display'] == 'XunY, XdeuxY' |
837 | ||
838 | ||
839 |
def test_block_post_condition_on_2nd_page(pub, blocks_feature): |
|
840 |
FormDef.wipe() |
|
841 |
BlockDef.wipe() |
|
842 | ||
843 |
block = BlockDef() |
|
844 |
block.name = 'foobar' |
|
845 |
block.fields = [ |
|
846 |
fields.StringField(id='123', required=True, label='Test', type='string', varname='foo'), |
|
847 |
] |
|
848 |
block.store() |
|
849 | ||
850 |
formdef = FormDef() |
|
851 |
formdef.name = 'form title' |
|
852 |
formdef.fields = [ |
|
853 |
fields.PageField(id='0', label='1st page', type='page'), |
|
854 |
fields.PageField(id='1', label='2nd page', type='page', post_conditions=[{ |
|
855 |
'condition': { |
|
856 |
'type': 'django', 'value': 'form_var_blockfoo|getlist:"foo"|sum == 5' |
|
857 |
}, 'error_message': 'You shall not pass.'}]), |
|
858 |
fields.BlockField(id='2', label='test', type='block:foobar', max_items=3, |
|
859 |
varname='blockfoo'), |
|
860 |
] |
|
861 |
formdef.store() |
|
862 | ||
863 |
app = get_app(pub) |
|
864 |
resp = app.get(formdef.get_url()) |
|
865 |
resp = resp.form.submit('submit') # -> second page |
|
866 |
resp.form['f2$element0$f123'] = 2 |
|
867 |
resp = resp.form.submit('f2$add_element') |
|
868 |
resp.form['f2$element1$f123'] = 3 |
|
869 |
resp = resp.form.submit('submit') # -> validation page |
|
870 |
assert 'You shall not pass.' not in resp.text |
|
871 |
resp = resp.form.submit('submit') # -> submit |
|
872 |
resp = resp.follow() |
|
837 |
- |