def test_unpack(self): t = forms_xso.OptionElement() o = forms_xso.Option() o.label = "fnord" o.value = "foobar" self.assertEqual( ("foobar", "fnord"), t.unpack(o) )
def test_accept_options_for_None(self): option = forms_xso.Option() option.value = "foobar" f = forms_xso.Field() f.type_ = None f.var = "foobar" f.options["foo"] = "bar" f.validate()
def test_accept_options_for_list_fields(self): types = {"list-single", "list-multi"} option = forms_xso.Option() option.value = "foobar" for type_ in types: f = forms_xso.Field() f.type_ = type_ f.var = "foobar" f.options["foo"] = "bar" f.validate()
def test_accept_options_for_list_fields(self): types = { forms_xso.FieldType.LIST_SINGLE, forms_xso.FieldType.LIST_MULTI, } option = forms_xso.Option() option.value = "foobar" for type_ in types: f = forms_xso.Field() f.type_ = type_ f.var = "foobar" f.options["foo"] = "bar" f.validate()
def test_reject_missing_value(self): opt = forms_xso.Option() with self.assertRaisesRegex(ValueError, "option is missing a value"): opt.validate()