-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from sigmavirus24/stronger-validation
Stronger validation
- Loading branch information
Showing
6 changed files
with
153 additions
and
16 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
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
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
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
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,35 @@ | ||
import unittest | ||
import inspect | ||
|
||
from betamax import exceptions | ||
|
||
|
||
def exception_classes(): | ||
for _, module_object in inspect.getmembers(exceptions): | ||
if inspect.isclass(module_object): | ||
yield module_object | ||
|
||
|
||
class TestExceptions(unittest.TestCase): | ||
def test_all_exceptions_are_betamax_errors(self): | ||
for exception_class in exception_classes(): | ||
assert isinstance(exception_class('msg'), exceptions.BetamaxError) | ||
|
||
def test_all_validation_errors_are_in_validation_error_map(self): | ||
validation_error_map_values = exceptions.validation_error_map.values() | ||
for exception_class in exception_classes(): | ||
if exception_class.__name__ == 'ValidationError' or \ | ||
not exception_class.__name__.endswith('ValidationError'): | ||
continue | ||
assert exception_class in validation_error_map_values | ||
|
||
def test_all_validation_errors_are_validation_errors(self): | ||
for exception_class in exception_classes(): | ||
if not exception_class.__name__.endswith('ValidationError'): | ||
continue | ||
assert isinstance(exception_class('msg'), | ||
exceptions.ValidationError) | ||
|
||
def test_invalid_option_is_validation_error(self): | ||
assert isinstance(exceptions.InvalidOption('msg'), | ||
exceptions.ValidationError) |
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