Beispiel #1
0
    def test_round_trip(self):
        test = twc.CompoundWidget(
            id='a',
            children=[
                twc.DisplayOnlyWidget(
                    child=twc.RepeatingWidget(id='q', child=twc.Widget)),
                twc.CompoundWidget(id='cc',
                                   children=[
                                       twc.Widget(id='d'),
                                       twc.Widget(id='e'),
                                   ])
            ])

        widgets = [
            test.children[0].child.rwbc[0],
            test.children[0].child.rwbc[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        data = dict(
            (w.compound_id, 'test%d' % i) for i, w in enumerate(widgets))
        testapi.request(1)
        vdata = test.validate(data)

        test = twc.core.request_local()['validated_widget']
        widgets = [
            test.children[0].child.children[0],
            test.children[0].child.children[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        for i, w in enumerate(widgets):
            eq_(w.value, 'test%d' % i)
Beispiel #2
0
 def test_display_only_widget(self):
     test = twc.DisplayOnlyWidget(child=compound_widget)
     testapi.request(1)
     inp = {'a': {'b': 'test', 'c': 'test2'}}
     out = test.validate(inp)
     assert (out == inp['a'])
     test = twc.core.request_local()['validated_widget']
     assert (test.child.children.b.value == 'test')
     assert (test.child.children.c.value == 'test2')
 def test_display_only(self):
     a = Child(id='a')
     test = twc.DisplayOnlyWidget(child=a, template='xyz', id_suffix='test')
     assert(a.parent is None)
     assert(test.child.parent.template == test.template)
     testapi.request(1)
     test = test.req()
     test.value = 10
     test.prepare()
     assert(test.child.value == 10)