751 |
751 |
tmpl = Template('{{form_user_name_identifier_0}}')
|
752 |
752 |
assert tmpl.render(context) == pub.user_class.select()[0].name_identifiers[0]
|
753 |
753 |
|
|
754 |
tmpl = Template('{% if form_user_email == "bar@localhost" %}HELLO{% endif %}')
|
|
755 |
assert tmpl.render(context) == 'HELLO'
|
|
756 |
|
754 |
757 |
def test_lazy_ezt_templates(pub, variable_test_data):
|
755 |
758 |
context = pub.substitutions.get_context_variables(mode='lazy')
|
756 |
759 |
tmpl = Template('[form_var_foo_foo]')
|
... | ... | |
759 |
762 |
tmpl = Template('[is form_var_foo_foo "bar"]HELLO[else]BYE[end]')
|
760 |
763 |
assert tmpl.render(context) == 'HELLO'
|
761 |
764 |
|
|
765 |
def test_lazy_formdata_fields(pub):
|
|
766 |
formdef = FormDef()
|
|
767 |
formdef.name = 'foobar'
|
|
768 |
formdef.url_name = 'foobar'
|
|
769 |
formdef.fields = [
|
|
770 |
fields.StringField(id='0', label='string', varname='string'),
|
|
771 |
fields.ItemField(id='1', label='item', varname='item', items=['Foo', 'Bar'])
|
|
772 |
]
|
|
773 |
formdef.store()
|
|
774 |
|
|
775 |
formdata = formdef.data_class()()
|
|
776 |
formdata.data = {'0': 'Foo', '1': 'Foo', '1_display': 'Foo'}
|
|
777 |
formdata.store()
|
|
778 |
|
|
779 |
pub.substitutions.feed(formdata)
|
|
780 |
context = pub.substitutions.get_context_variables(mode='lazy')
|
|
781 |
|
|
782 |
tmpl = Template('{% if form_var_string == "Foo" %}HELLO{% endif %}')
|
|
783 |
assert tmpl.render(context) == 'HELLO'
|
|
784 |
tmpl = Template('{% if form_var_item == "Foo" %}HELLO{% endif %}')
|
|
785 |
assert tmpl.render(context) == 'HELLO'
|
|
786 |
|
|
787 |
tmpl = Template('{% if form_var_string != "Foo" %}HELLO{% endif %}')
|
|
788 |
assert tmpl.render(context) == ''
|
|
789 |
tmpl = Template('{% if form_var_item != "Foo" %}HELLO{% endif %}')
|
|
790 |
assert tmpl.render(context) == ''
|
|
791 |
|
762 |
792 |
def test_form_digest_date(pub):
|
763 |
793 |
formdef = FormDef()
|
764 |
794 |
formdef.name = 'foobar'
|