class TestOpenIdValidator(unittest.TestCase):
    """Tests for the OpenId validator"""

    def setUp(self):
        self.validator = OpenId(add_schema=False)

    def test_url(self):
        self.assertEqual(self.validator.to_python('http://example.org'),
                         'http://example.org')

    def test_iname(self):
        self.assertEqual(self.validator.to_python('=Gustavo'), '=Gustavo')

    def test_inumber(self):
        self.assertEqual(self.validator.to_python('!!1000'), '!!1000')

    def test_email(self):
        """Email addresses are not valid OpenIds!"""
        self.assertRaises(Invalid, self.validator.to_python,
                          "*****@*****.**")

    def test_prepending_schema(self):
        validator = OpenId(add_schema=True)
        self.assertEqual(validator.to_python("example.org"),
                         "http://example.org")
        self.assertEqual(validator.to_python("=Gustavo"),
                         "xri://=Gustavo")
        self.assertEqual(validator.to_python("!!1000"),
                         "xri://!!1000")
 def test_prepending_schema(self):
     validator = OpenId(add_schema=True)
     self.assertEqual(validator.to_python("example.org"),
                      "http://example.org")
     self.assertEqual(validator.to_python("=Gustavo"),
                      "xri://=Gustavo")
     self.assertEqual(validator.to_python("!!1000"),
                      "xri://!!1000")
Example #3
0
 class UserForm(FormBase):
     __entity__ = User
     user_name = Field(validator=OpenId())
Example #4
0
 class UserForm(FormBase):
     __entity__ = User
     user_name = OpenId()
 def setUp(self):
     self.validator = OpenId(add_schema=False)