Exemplo n.º 1
0
 def test_field_jid_multi(self):
     field = Field(field_type="jid-multi", value=[JID(u"*****@*****.**"), JID(u"*****@*****.**")])
     self.failUnlessEqual(field.value, [JID(u"*****@*****.**"), JID(u"*****@*****.**")])
     self.failUnlessEqual(field.values, [u"*****@*****.**", u"*****@*****.**"])
     field = Field(field_type="jid-multi", values=[u"*****@*****.**", u"example.com"])
     self.failUnlessEqual(field.value, [JID(u"*****@*****.**"), JID(u"example.com")])
     self.failUnlessEqual(field.values, [u"*****@*****.**", u"example.com"])
     field.value = [u"*****@*****.**"]
     self.failUnlessEqual(field.value, [JID(u"*****@*****.**")])
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
Exemplo n.º 2
0
 def test_field_boolean(self):
     field = Field(field_type="boolean", value=True)
     self.failUnlessEqual(field.value, True)
     self.failUnlessEqual(field.values, [u"1"])
     field = Field(field_type="boolean", values=[u"0"])
     self.failUnlessEqual(field.value, False)
     self.failUnlessEqual(field.values, [u"0"])
     field.value = True
     self.failUnlessEqual(field.value, True)
     self.failUnlessEqual(field.values, [u"1"])
Exemplo n.º 3
0
 def test_field_list_multi(self):
     field = Field(field_type="list-multi", value=[u"item1", u"item2"])
     self.failUnlessEqual(field.value, [u"item1", u"item2"])
     self.failUnlessEqual(field.values, [u"item1", u"item2"])
     field = Field(field_type="list-multi", values=[u"item", u""])
     self.failUnlessEqual(field.value, [u"item", u""])
     self.failUnlessEqual(field.values, [u"item", u""])
     field.value = [u"a", u"b"]
     self.failUnlessEqual(field.value, [u"a", u"b"])
     self.failUnlessEqual(field.values, [u"a", u"b"])
Exemplo n.º 4
0
 def test_field_jid_single(self):
     field = Field(field_type="jid-single", value=JID(u"*****@*****.**"))
     self.failUnlessEqual(field.value, JID(u"*****@*****.**"))
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
     field = Field(field_type="jid-single", values=[u"*****@*****.**"])
     self.failUnlessEqual(field.value, JID(u"*****@*****.**"))
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
     field.value = JID(u"example.com")
     self.failUnlessEqual(field.value, JID(u"example.com"))
     self.failUnlessEqual(field.values, [u"example.com"])
Exemplo n.º 5
0
 def test_field_text_private(self):
     field = Field(field_type="text-private", value=u"bleble")
     self.failUnlessEqual(field.value,u"bleble")
     self.failUnlessEqual(field.values,[u"bleble"])
     field = Field(field_type="text-private", values=[u"abcd"])
     self.failUnlessEqual(field.value,u"abcd")
     self.failUnlessEqual(field.values,[u"abcd"])
     field.value = u"zażółć gęślą jaźń"
     self.failUnlessEqual(field.value, u"zażółć gęślą jaźń")
     self.failUnlessEqual(field.values,[u"zażółć gęślą jaźń"])
Exemplo n.º 6
0
 def test_field_list_single(self):
     field = Field(field_type="list-single", value=u"bleble")
     self.failUnlessEqual(field.value,u"bleble")
     self.failUnlessEqual(field.values,[u"bleble"])
     field = Field(field_type="list-single", values=[u"abcd"])
     self.failUnlessEqual(field.value,u"abcd")
     self.failUnlessEqual(field.values,[u"abcd"])
     field.value = u"zażółć gęślą jaźń"
     self.failUnlessEqual(field.value, u"zażółć gęślą jaźń")
     self.failUnlessEqual(field.values,[u"zażółć gęślą jaźń"])
Exemplo n.º 7
0
 def test_field_boolean(self):
     field = Field(field_type="boolean", value=True)
     self.failUnlessEqual(field.value, True)
     self.failUnlessEqual(field.values, [u"1"])
     field = Field(field_type="boolean", values=[u"0"])
     self.failUnlessEqual(field.value, False)
     self.failUnlessEqual(field.values, [u"0"])
     field.value = True
     self.failUnlessEqual(field.value, True)
     self.failUnlessEqual(field.values, [u"1"])
Exemplo n.º 8
0
 def test_field_jid_single(self):
     field = Field(field_type="jid-single", value=JID(u"*****@*****.**"))
     self.failUnlessEqual(field.value, JID(u"*****@*****.**"))
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
     field = Field(field_type="jid-single", values=[u"*****@*****.**"])
     self.failUnlessEqual(field.value, JID(u"*****@*****.**"))
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
     field.value = JID(u"example.com")
     self.failUnlessEqual(field.value, JID(u"example.com"))
     self.failUnlessEqual(field.values, [u"example.com"])
Exemplo n.º 9
0
 def test_field_list_multi(self):
     field = Field(field_type="list-multi", value=[u"item1", u"item2"])
     self.failUnlessEqual(field.value, [u"item1", u"item2"])
     self.failUnlessEqual(field.values, [u"item1", u"item2"])
     field = Field(field_type="list-multi", values=[u"item", u""])
     self.failUnlessEqual(field.value, [u"item", u""])
     self.failUnlessEqual(field.values, [u"item", u""])
     field.value = [u"a", u"b"]
     self.failUnlessEqual(field.value, [u"a", u"b"])
     self.failUnlessEqual(field.values, [u"a", u"b"])
Exemplo n.º 10
0
 def test_field_list_single(self):
     field = Field(field_type="list-single", value=u"bleble")
     self.failUnlessEqual(field.value, u"bleble")
     self.failUnlessEqual(field.values, [u"bleble"])
     field = Field(field_type="list-single", values=[u"abcd"])
     self.failUnlessEqual(field.value, u"abcd")
     self.failUnlessEqual(field.values, [u"abcd"])
     field.value = u"zażółć gęślą jaźń"
     self.failUnlessEqual(field.value, u"zażółć gęślą jaźń")
     self.failUnlessEqual(field.values, [u"zażółć gęślą jaźń"])
Exemplo n.º 11
0
 def test_field_text_private(self):
     field = Field(field_type="text-private", value=u"bleble")
     self.failUnlessEqual(field.value, u"bleble")
     self.failUnlessEqual(field.values, [u"bleble"])
     field = Field(field_type="text-private", values=[u"abcd"])
     self.failUnlessEqual(field.value, u"abcd")
     self.failUnlessEqual(field.values, [u"abcd"])
     field.value = u"zażółć gęślą jaźń"
     self.failUnlessEqual(field.value, u"zażółć gęślą jaźń")
     self.failUnlessEqual(field.values, [u"zażółć gęślą jaźń"])
Exemplo n.º 12
0
 def test_field_jid_multi(self):
     field = Field(
         field_type="jid-multi",
         value=[JID(u"*****@*****.**"),
                JID(u"*****@*****.**")])
     self.failUnlessEqual(
         field.value,
         [JID(u"*****@*****.**"),
          JID(u"*****@*****.**")])
     self.failUnlessEqual(field.values,
                          [u"*****@*****.**", u"*****@*****.**"])
     field = Field(field_type="jid-multi",
                   values=[u"*****@*****.**", u"example.com"])
     self.failUnlessEqual(field.value,
                          [JID(u"*****@*****.**"),
                           JID(u"example.com")])
     self.failUnlessEqual(field.values,
                          [u"*****@*****.**", u"example.com"])
     field.value = [u"*****@*****.**"]
     self.failUnlessEqual(field.value, [JID(u"*****@*****.**")])
     self.failUnlessEqual(field.values, [u"*****@*****.**"])
Exemplo n.º 13
0
 def build_form_direct(self, form_type, title, instructions, field_data):
     fields = []
     for name, ftype, values, label, options, required, desc in field_data:
         foptions = []
         for olabel, ovalue in options:
             foptions.append(Option(ovalue, olabel))
         field = Field(name=name,
                       field_type=ftype,
                       values=values,
                       label=label,
                       options=foptions,
                       required=required,
                       desc=desc)
         fields.append(field)
     form = Form(form_type,
                 title=title,
                 instructions=instructions,
                 fields=fields)
     return form