def test_deferred_value_subclass(self): class TestWidget(twc.Widget): id = 'test' inline_engine_name = 'mako' template = "<p>${w.value}</p>" value = twc.Param(attribute=True) test = TestWidget expected = "<p>test</p>" # This should be fine eq_(test(value=twc.Deferred(lambda: 'test')).display(), expected) # This one is more tricky. eq_(test(value=twc.Deferred(lambda: 'test'))().display(), expected)
class operator(twf.TableLayout): uid = twf.SingleSelectField(label="SUNetID", options=twc.Deferred(user_list), validator=twc.Any( twc.StringLengthValidator(min=0, max=0), UserExists()))
def test_deferred_value_no_subclass(self): test = twc.Widget(id='test', template="<p>${w.value}</p>", inline_engine_name="mako", value=twc.Deferred(lambda: 'test')) assert (test.value != 'test') ins = test.req() ins.prepare() assert (ins.value == 'test') assert (test.display() == "<p>test</p>")
def test_deferred_value_subclass_with_display(self): class TestWidget(twc.Widget): id = 'test' inline_engine_name = 'mako' template = "<p>${w.value}</p>" value = twc.Param() test = TestWidget eq_(test.display(value="test"), "<p>test</p>") eq_(test.display(value=twc.Deferred(lambda: 'test')), "<p>test</p>")
class BillInfo(twf.ListFieldSet): label = l_("Dati Fatturazione") key = 'bill_info' company = twf.TextField(css_class="form-control", label=l_("Ragione Sociale")) vat = twf.TextField(css_class="form-control", label=l_("Partita IVA")) fiscal_code = twf.TextField(css_class="form-control", label=l_("Codice Fiscale")) address = twf.TextField(css_class="form-control", label=l_("Indirizzo")) city = twf.TextField(css_class="form-control", label=l_("Città ")) province = twf.TextField(css_class="form-control", label=l_("Provincia")) zip_code = twf.TextField(css_class="form-control", label=l_("CAP")) country = twf.SingleSelectField( css_class="form-control", prompt_text=None, label=l_("Stato"), options=twc.Deferred(lambda: [('IT', l_('Stato'))]))
class ShipmentInfo(twf.ListFieldSet): label = l_("Dati Spedizione") key = 'shipment_info' receiver = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Destinatario")) address = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Indirizzo")) city = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Città ")) province = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Provincia")) zip_code = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("CAP")) country = twf.SingleSelectField( css_class="form-control", prompt_text=None, label=l_("Stato"), options=twc.Deferred(lambda: [('IT', l_('Stato'))]))
def test_deferred(self): test = twc.Widget(id='test', template=twc.Deferred(lambda: 'test')) assert (test.template != 'test') ins = test.req() ins.prepare() assert (ins.template == 'test')
class child(twf.TableForm): action = 'post_edit' id = twf.HiddenField() owner = twf.SingleSelectField(options=twc.Deferred(get_owners), validator=twc.Required) name = twf.TextField(validator=twc.All(twc.StringLengthValidator(min=1), ExperimentDoesntExist('owner'))) timestamp = twf.LabelField()
class child(twf.TableLayout): owner = twf.SingleSelectField(options=twc.Deferred(get_owners), validator=twc.Required) name = twf.TextField(validator=twc.All(twc.StringLengthValidator(min=1), ExperimentDoesntExist('owner')))