UPD: dav_registration: added tests.
This commit is contained in:
46
dav_registration/tests/test_validators.py
Normal file
46
dav_registration/tests/test_validators.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from ..validators import DAVNumberValidator
|
||||
|
||||
|
||||
class TestCase(SimpleTestCase):
|
||||
def test_dav_number_validator(self):
|
||||
valid_data = (
|
||||
'131/00/1',
|
||||
'1',
|
||||
'22',
|
||||
'333',
|
||||
'1/22/22',
|
||||
'54321/54321/54321*54321',
|
||||
'54321/54321/54321*54321*4321*4321',
|
||||
'54321/54321/54321*54321*4321*4321*87654321',
|
||||
'54321*54321',
|
||||
'54321*54321*4321*4321',
|
||||
'54321*54321*4321*4321*87654321',
|
||||
)
|
||||
invalid_data = (
|
||||
'131/00/',
|
||||
'1/1/1',
|
||||
'1/1',
|
||||
'abc',
|
||||
'131/00/abc',
|
||||
'abc/00/131',
|
||||
'131/ab/131',
|
||||
)
|
||||
|
||||
v = DAVNumberValidator
|
||||
|
||||
for val in valid_data:
|
||||
try:
|
||||
v(val)
|
||||
except ValidationError as e: # pragma: no cover
|
||||
self.fail('%s: %s' % (val, e))
|
||||
|
||||
for val in invalid_data:
|
||||
try:
|
||||
v(val)
|
||||
except ValidationError:
|
||||
pass
|
||||
else: # pragma: no cover
|
||||
self.fail('%s: no ValidationError was raised' % val)
|
||||
Reference in New Issue
Block a user