-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4284cba
commit de119fc
Showing
2 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from booby.errors import ValidationError | ||
from repose.tests import TestCase | ||
|
||
|
||
class RangeValdiatorTestCase(TestCase): | ||
|
||
def test_min_max(self): | ||
from repose.validators import Range | ||
v = Range(min=10, max=20) | ||
v.validate(None) | ||
v.validate(10) | ||
v.validate(20) | ||
self.assertRaises(ValidationError, v.validate, -1) | ||
self.assertRaises(ValidationError, v.validate, 21) | ||
self.assertRaises(ValidationError, v.validate, 'abc') | ||
|
||
def test_min(self): | ||
from repose.validators import Range | ||
v = Range(min=10) | ||
v.validate(None) | ||
v.validate(10) | ||
v.validate(20) | ||
v.validate(10000) | ||
self.assertRaises(ValidationError, v.validate, -1) | ||
self.assertRaises(ValidationError, v.validate, 'abc') | ||
|
||
def test_max(self): | ||
from repose.validators import Range | ||
v = Range(max=20) | ||
v.validate(None) | ||
v.validate(-1) | ||
v.validate(10) | ||
v.validate(20) | ||
self.assertRaises(ValidationError, v.validate, 21) | ||
self.assertRaises(ValidationError, v.validate, 'abc') | ||
|
||
|
||
class DictionaryValidatorTestCase(TestCase): | ||
|
||
def test_validate(self): | ||
from repose.validators import Dictionary | ||
v = Dictionary() | ||
v.validate(None) | ||
v.validate({}) | ||
v.validate({'a': 123}) | ||
self.assertRaises(ValidationError, v.validate, []) | ||
self.assertRaises(ValidationError, v.validate, 213) | ||
self.assertRaises(ValidationError, v.validate, 'abc') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters