示例#1
0
 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)
     )
示例#2
0
    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()
示例#3
0
    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()
示例#4
0
    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()
示例#5
0
 def test_reject_missing_value(self):
     opt = forms_xso.Option()
     with self.assertRaisesRegex(ValueError,
                                 "option is missing a value"):
         opt.validate()