def test_get_value_return_list_of_values_if_multiple_selection_is_true(self): component = Select('x', multiple=True) component.add_option('a', 'b') self.assertEquals([], component.get('value')) component.set('value', ['b']) self.assertEquals(['b'], component.get('value'))
def test_get_value_return_value_if_multiple_selection_is_false(self): component = Select('x', multiple=False) component.add_option('a', 'b') self.assertEquals(None, component.get('value')) component.set('value', 'b') self.assertEquals('b', component.get('value'))
def test_set_value_select_options_with_the_value(self): component = Select('x') component.add_option('a', 'b') component.set('value', 'b') self.assertEquals('<select name="x"><option selected="selected" value="b">a</option></select>', component.as_html())
def test_set_value_accept_multiple_values(self): component = Select('x') component.add_option('a', 'b') component.set('value', ['b']) self.assertEquals('<select name="x"><option selected="selected" value="b">a</option></select>', component.as_html())
def test_can_add_selected_options(self): component = Select('x') component.add_option('a', 'b', selected=True) self.assertEquals('<select name="x"><option selected="selected" value="b">a</option></select>', component.as_html())