def render(self): data = {self.name: self.value} if self.is_value_bound else {} return html.vcheckbox(self.name, self.expected_value, data, default=self.default, _id=self._id_prefix + self.name, **self.kwargs)
def test_vcheckbox_default(): s = mod.vcheckbox('foo', 'fooval', {}, True) assert 'checked' in s s = mod.vcheckbox('foo', 'fooval', {}, False) assert 'checked' not in s
def test_vcheckbox_values_list(): s = mod.vcheckbox('foo', 'fooval', {'foo': ['fooval', 'barval']}) assert 'checked' in s
def test_vcheckbox_value_no_partial_match(): s = mod.vcheckbox('foo', 'fooval', {'foo': 'foovaliant'}) assert 'checked' not in s
def test_vcheckbox_value_with_string_coertion(): s = mod.vcheckbox('foo', 1, {'foo': '1'}) assert 'checked' in s
def test_vcheckbox_value(): s = mod.vcheckbox('foo', 'fooval', {'foo': 'fooval'}) assert 'checked' in s
def test_vcheckbox(): s = mod.vcheckbox('foo', 'fooval', {}) assert_tag(s, 'input') assert_type(s, 'checkbox') assert_value(s, 'fooval') assert_attr(s, 'id', 'foo')