Back to index

plone3  3.1.7
Public Member Functions
validation.tests.test_validation.TestValidation Class Reference
Inheritance diagram for validation.tests.test_validation.TestValidation:
Inheritance graph
[legend]
Collaboration diagram for validation.tests.test_validation.TestValidation:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_inNumericRange
def test_isPrintable
def test_isSSN
def test_isUSPhoneNumber
def test_isURL
def test_isEmail
def test_isMailto
def test_isUnixLikeName
def test_isValidId

Detailed Description

Definition at line 8 of file test_validation.py.


Member Function Documentation

Definition at line 10 of file test_validation.py.

00010 
00011     def test_inNumericRange(self):
00012         v = validation.validatorFor('inNumericRange')
00013         self.failUnlessEqual(v(10, 1, 20), 1)
00014         self.failUnlessEqual(v('10', 1, 20), 1)
00015         self.failIfEqual(v(0, 4, 5), 1)

Definition at line 45 of file test_validation.py.

00045 
00046     def test_isEmail(self):
00047         v = validation.validatorFor('isEmail')
00048         self.failUnlessEqual(v('test@test.com'), 1)
00049         self.failIfEqual(v('@foo.bar'), 1)
00050         self.failIfEqual(v('me'), 1)

Definition at line 51 of file test_validation.py.

00051 
00052     def test_isMailto(self):
00053         v = validation.validatorFor('isMailto')
00054         self.failUnlessEqual(v('mailto:test@test.com'), 1)
00055         self.failIfEqual(v('test@test.com'), 1)
00056         self.failIfEqual(v('mailto:@foo.bar'), 1)
00057         self.failIfEqual(v('@foo.bar'), 1)
00058         self.failIfEqual(v('mailto:'), 1)
00059         self.failIfEqual(v('me'), 1)

Definition at line 16 of file test_validation.py.

00016 
00017     def test_isPrintable(self):
00018         v = validation.validatorFor('isPrintable')
00019         self.failUnlessEqual(v('text'), 1)
00020         self.failIfEqual(v('\u203'), 1)
00021         self.failIfEqual(v(10), 1)

Definition at line 22 of file test_validation.py.

00022 
00023     def test_isSSN(self):
00024         v = validation.validatorFor('isSSN')
00025         self.failUnlessEqual(v('111223333'), 1)
00026         self.failUnlessEqual(v('111-22-3333', ignore=r'-'), 1)

Definition at line 60 of file test_validation.py.

00060 
00061     def test_isUnixLikeName(self):
00062         v = validation.validatorFor('isUnixLikeName')
00063         self.failUnlessEqual(v('abcd'), 1)
00064         self.failUnless(v('a_123456'), 1)
00065         self.failIfEqual(v('123'), 1)
00066         self.failIfEqual(v('ab.c'), 1)
00067         self.failIfEqual(v('ab,c'), 1)
00068         self.failIfEqual(v('aaaaaaaab'), 1) # too long
        

Definition at line 36 of file test_validation.py.

00036 
00037     def test_isURL(self):
00038         v = validation.validatorFor('isURL')
00039         self.failUnlessEqual(v('http://foo.bar:8080/manage'), 1)
00040         self.failUnlessEqual(v('https://foo.bar:8080/manage'), 1)
00041         self.failUnlessEqual(v('irc://tiran@irc.freenode.net:6667/#plone'), 1)
00042         self.failUnlessEqual(v('fish://tiran:password@myserver/~/'), 1)
00043         self.failIfEqual(v('http://\n'), 1)
00044         self.failIfEqual(v('../foo/bar'), 1)

Definition at line 27 of file test_validation.py.

00027 
00028     def test_isUSPhoneNumber(self):
00029         v = validation.validatorFor('isUSPhoneNumber')
00030         self.failUnlessEqual(v('(212) 555-1212',
00031                                ignore=r'[\s\(\)\-]'), 1)
00032         self.failUnlessEqual(v('2125551212',
00033                                ignore=r'[\s\(\)\-]'), 1)
00034 
00035         self.failUnlessEqual(v('(212) 555-1212'), 1)

Definition at line 69 of file test_validation.py.

00069 
00070     def test_isValidId(self):
00071         v = validation.validatorFor("isValidId")
00072         self.failIfEqual(v("a b", object()), 1)
00073         # TODO: more tests require a site
00074 
        

The documentation for this class was generated from the following file: