1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import pytest
- from pytest import mark, raises
- from bottle import template
- @mark.parametrize('expected, params', [
- ("""<div class="pure-u-1">
- <label for="select-id">Choose: </label>
- <select id="select-id" name="select-name" size=10 multiple style="width: calc(100% - 1em); margin: 0 1em 1em">
- <option value="hint" disabled >hint</option>
- <optgroup label="Group">
- <option value="val1-to-backend" >val1</option>
- <option value="val2" disabled >val2</option>
- </optgroup>
- </select>
- </div>""", {
- "id": "select-id", "label": "Choose: ", "name": "select-name",
- "hint": "hint", "multiple": True, "children": [{"optgroup": "Group", "options": [
- {
- "value": "val1-to-backend",
- "display": "val1",
- },
- {
- "value": "val2",
- "disabled": True,
- }, ]}, ]}),
- ("""<div class="pure-u-1">
- <select id="select-unit-id" name="unit" size=10 style="width: calc(100% - 1em); margin: 0 1em 1em">
- <option value="val1" >val1</option>
- <option value="val2" selected>val2</option>
- </select>
- </div>""",{
- "id": "select-unit-id", "name": "unit", "children": [{ "options": [
- {
- "value": "val1",
- },
- {
- "value": "val2",
- "selected": True,
- }, ]}, ]}),
- ("""<div class="pure-u-1">
- <label for="select-id">Choose: </label>
- <select id="select-id" name="select-name" size=10 multiple style="width: calc(100% - 1em); margin: 0 1em 1em">
- <option value="hint" disabled >hint</option>
- <optgroup label="Group">
- <option value="val1-to-backend" >val1</option>
- <option value="val2" disabled >val2</option>
- </optgroup>
- <option value="val1" >val1</option>
- <option value="val2" selected>val2</option>
- </select>
- </div>""",{
- "id": "select-id", "label": "Choose: ", "name": "select-name",
- "hint": "hint", "multiple": True, "children": [
- {"optgroup": "Group", "options": [
- {
- "value": "val1-to-backend",
- "display": "val1",
- },
- {
- "value": "val2",
- "disabled": True,
- }
- ]},
- { "options": [
- {
- "value": "val1",
- },
- {
- "value": "val2",
- "selected": True,
- },
- ]},
- ]})
- ])
- def test_select_render_exact(expected, params):
- assert template('select', **params) == expected
|