Exemple #1
0
 def test_set_selected_option__deselect_others(self):
     select = Select()
     option1 = select.create_option("L1", selected=True)
     option2 = select.create_option("L2")
     select.selected_option = option2
     assert_false(option1.selected)
     assert_is(option2, select.selected_option)
Exemple #2
0
 def test_set_selected_option__deselect_others(self):
     select = Select()
     option1 = select.create_option("L1", selected=True)
     option2 = select.create_option("L2")
     select.selected_option = option2
     assert_false(option1.selected)
     assert_is(option2, select.selected_option)
Exemple #3
0
 def test_create_option__option_object(self):
     select = Select()
     option = select.create_option("Option Label", "test-value",
                                   selected=True)
     assert_equal("option", option.element_name)
     assert_equal("test-value", option.value)
     assert_true(option.selected)
Exemple #4
0
 def test_create_group(self):
     select = Select()
     group = select.create_group("Group Label")
     assert_equal("Group Label", group.label)
     assert_equal(
         '<select><optgroup label="Group Label"></optgroup>'
         '</select>', str(select))
Exemple #5
0
 def test_create_option__option_object(self):
     select = Select()
     option = select.create_option(
         "Option Label", "test-value", selected=True
     )
     assert_equal("option", option.element_name)
     assert_equal("test-value", option.value)
     assert_true(option.selected)
Exemple #6
0
 def test_create_option__selected(self):
     select = Select()
     option = select.create_option("Option Label", "test-value",
                                   selected=True)
     assert_is(option, select.selected_option)
     assert_equal(
         '<select><option selected="selected" value="test-value">'
         'Option Label</option></select>',
         str(select))
Exemple #7
0
 def test_get_selected_option__return_first(self):
     select = Select()
     option1 = Option("L1")
     option1.selected = True
     option2 = Option("L2")
     option2.selected = True
     select.append(option1)
     select.append(option2)
     assert_is(option1, select.selected_option)
Exemple #8
0
 def test_create_option__selected(self):
     select = Select()
     option = select.create_option("Option Label",
                                   "test-value",
                                   selected=True)
     assert_is(option, select.selected_option)
     assert_equal(
         '<select><option selected="selected" value="test-value">'
         'Option Label</option></select>', str(select))
Exemple #9
0
 def test_get_selected_option__return_first(self):
     select = Select()
     option1 = Option("L1")
     option1.selected = True
     option2 = Option("L2")
     option2.selected = True
     select.append(option1)
     select.append(option2)
     assert_is(option1, select.selected_option)
Exemple #10
0
 def test_set_selected_option(self):
     select = Select()
     select.create_option("L1")
     option = select.create_option("L2")
     select.create_option("L3")
     select.selected_option = option
     assert_true(option.selected)
     assert_is(option, select.selected_option)
Exemple #11
0
 def test_set_selected_value(self):
     select = Select()
     select.create_option("L1", "v1")
     option = select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     select.selected_value = "v2"
     assert_equal("v2", select.selected_value)
     assert_is(option, select.selected_option)
     assert_true(option.selected)
Exemple #12
0
 def test_set_selected_option(self):
     select = Select()
     select.create_option("L1")
     option = select.create_option("L2")
     select.create_option("L3")
     select.selected_option = option
     assert_true(option.selected)
     assert_is(option, select.selected_option)
Exemple #13
0
 def test_set_selected_value(self):
     select = Select()
     select.create_option("L1", "v1")
     option = select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     select.selected_value = "v2"
     assert_equal("v2", select.selected_value)
     assert_is(option, select.selected_option)
     assert_true(option.selected)
Exemple #14
0
 def test_create_option(self):
     select = Select()
     select.create_option("Option Label")
     assert_equal(
         "<select><option>Option Label</option></select>", str(select)
     )
Exemple #15
0
 def test_get_selected_option__non_option_elements(self):
     select = Select()
     select.append("String Content")
     assert_is_none(select.selected_option)
Exemple #16
0
 def test_get_selected_value__implicit_value(self):
     select = Select()
     select.create_option("L1")
     select.create_option("L2", selected=True)
     assert_equal("L2", select.selected_value)
Exemple #17
0
 def test_create_option__option_object__default_value(self):
     select = Select()
     option = select.create_option("Option Label")
     assert_equal("Option Label", option.value)
Exemple #18
0
 def test_get_selected_option__in_option_group(self):
     select = Select()
     group = select.create_group("")
     option = group.create_option("")
     option.selected = True
     assert_is(option, select.selected_option)
Exemple #19
0
 def test_create_option__selected_deselect_others(self):
     select = Select()
     option = select.create_option("L1", selected=True)
     select.create_option("L2", selected=True)
     assert_false(option.selected)
Exemple #20
0
 def test_set_selected_value__value_not_found(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     with assert_raises(ValueError):
         select.selected_value = "not-found"
Exemple #21
0
 def test_get_selected_value__no_selected(self):
     select = Select()
     select.create_option("L1", "v1")
     assert_is_none(select.selected_value)
Exemple #22
0
 def test_get_selected_value__implicit_value(self):
     select = Select()
     select.create_option("L1")
     select.create_option("L2", selected=True)
     assert_equal("L2", select.selected_value)
Exemple #23
0
 def test_set_selected_option__string_children(self):
     select = Select()
     select.append("String Content")
     option = select.create_option("L1")
     select.selected_option = option
Exemple #24
0
 def test_get_selected_option(self):
     select = Select()
     select.create_option("L1", "v1")
     option = select.create_option("L2", "v2", selected=True)
     select.create_option("L3", "v3")
     assert_is(option, select.selected_option)
Exemple #25
0
 def test_create_option__selected_deselect_others(self):
     select = Select()
     option = select.create_option("L1", selected=True)
     select.create_option("L2", selected=True)
     assert_false(option.selected)
Exemple #26
0
 def test_attributes(self):
     select = Select()
     assert_false(select.disabled)
Exemple #27
0
 def test_create_option__option_object__default_value(self):
     select = Select()
     option = select.create_option("Option Label")
     assert_equal("Option Label", option.value)
Exemple #28
0
 def test_get_selected_option__non_option_elements(self):
     select = Select()
     select.append("String Content")
     assert_is_none(select.selected_option)
Exemple #29
0
 def test_get_selected_option(self):
     select = Select()
     select.create_option("L1", "v1")
     option = select.create_option("L2", "v2", selected=True)
     select.create_option("L3", "v3")
     assert_is(option, select.selected_option)
Exemple #30
0
 def test_get_selected_option__option_group_has_string_child(self):
     select = Select()
     group = select.create_group("")
     group.append("XXX")
     assert_is_none(select.selected_option)
Exemple #31
0
 def test_get_selected_option__no_selected_elements(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     assert_is_none(select.selected_option)
Exemple #32
0
 def test_get_selected_option__option_group_has_string_child(self):
     select = Select()
     group = select.create_group("")
     group.append("XXX")
     assert_is_none(select.selected_option)
Exemple #33
0
 def test_get_selected_option__in_option_group(self):
     select = Select()
     group = select.create_group("")
     option = group.create_option("")
     option.selected = True
     assert_is(option, select.selected_option)
Exemple #34
0
 def test_create_option(self):
     select = Select()
     select.create_option("Option Label")
     assert_equal('<select><option>Option Label</option></select>',
                  str(select))
Exemple #35
0
 def test_attributes(self):
     select = Select()
     select.autocomplete = "username"
     assert_false(select.disabled)
     assert_equal('<select autocomplete="username"></select>', str(select))
Exemple #36
0
 def test_with_name(self):
     select = Select("my-name")
     assert_equal("my-name", select.name)
     assert_equal('<select name="my-name"></select>', str(select))
Exemple #37
0
 def test_set_selected_option__string_children(self):
     select = Select()
     select.append("String Content")
     option = select.create_option("L1")
     select.selected_option = option
Exemple #38
0
 def test_without_name(self):
     select = Select()
     assert_equal("", select.name)
     assert_equal("<select></select>", str(select))
Exemple #39
0
 def test_get_selected_value__no_selected(self):
     select = Select()
     select.create_option("L1", "v1")
     assert_is_none(select.selected_value)
Exemple #40
0
 def test_get_selected_option__no_selected_elements(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     assert_is_none(select.selected_option)
Exemple #41
0
 def test_set_selected_value__value_not_found(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     with assert_raises(ValueError):
         select.selected_value = "not-found"
Exemple #42
0
 def test_create_group(self):
     select = Select()
     group = select.create_group("Group Label")
     assert_equal("Group Label", group.label)
     assert_equal('<select><optgroup label="Group Label"></optgroup>'
                  '</select>', str(select))