Exemplo n.º 1
0
def test_form_getitem_doesnt_match():
    form_text = html.body(
        html.form(
            html.input(name="foo", value="a")),
        html.input(name="foo", value="b"))
    agent = TestAgent(wz.Response([form_text]))
    form_page = agent.get(u'/')
    form = form_page.one(u"//form")
    assert form[u"foo"] == u"a"
Exemplo n.º 2
0
def radio_button(name, value='yes', checked=False, **attr):
    """Render a checkbox."""
    return html.input(type='radio',
                      value=value,
                      name=name,
                      checked=checked,
                      **attr)
Exemplo n.º 3
0
def checkbox(name, checked=False, value='yes', **attr):
    """Render a checkbox."""
    return html.input(type='checkbox',
                      name=name,
                      value=value,
                      checked=checked,
                      **attr)
Exemplo n.º 4
0
def test_form_getitem():
    form_text = html.div(
        html.p(
            html.input(type="text", name="foo", value="flam")),
        html.p(
            html.select(
                html.option(value="a", selected=True),
                html.option(value="b"),
                name="bar"))
    )
    form_page = TestAgent(FormApp(form_text)).get(u'/')
    form = form_page.one(u'//form')
    assert form['foo'] == "flam"
    assert form['bar'] == "a"
    form["foo"] = u"flibble"
    form["bar"] = u"a"
    assert form.one(u'//input').value == u'flibble'
    assert form.one(u'//select').value == u'a'

    # Test checkboxes
    form_page = TestAgent(TestApp()).get('/form-checkbox')
    form = form_page.one('//form')
    assert form['a'] == []
    assert form['b'] == ["A"]
Exemplo n.º 5
0
def input_field(name, value='', type='text', **attr):
    """Render an input field."""
    return html.input(name=name, value=value, type=type, **attr)
Exemplo n.º 6
0
def radio_button(name, value='yes', checked=False, **attr):
    """Render a checkbox."""
    return html.input(type='radio', value=value, name=name,
                      checked=checked, **attr)
Exemplo n.º 7
0
def checkbox(name, checked=False, value='yes', **attr):
    """Render a checkbox."""
    return html.input(type='checkbox', name=name, value=value,
                      checked=checked, **attr)
Exemplo n.º 8
0
def input_field(name, value='', type='text', **attr):
    """Render an input field."""
    return html.input(name=name, value=value, type=type, **attr)