-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#293] don't allow any whitespace for tokens
- Loading branch information
Showing
4 changed files
with
24 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.test import SimpleTestCase | ||
|
||
from openklant.components.token.validators import validate_non_empty_chars | ||
from openklant.components.token.validators import validate_whitespace | ||
|
||
|
||
class WhiteSpaceValidatorTestCase(SimpleTestCase): | ||
def test_characters_only(self): | ||
self.assertIsNone(validate_non_empty_chars("test123")) | ||
self.assertIsNone(validate_whitespace("test123")) | ||
|
||
def test_trailing_whitespace(self): | ||
self.assertIsNone(validate_non_empty_chars("test123 ")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace("test123 ") | ||
|
||
def test_leading_whitespace(self): | ||
self.assertIsNone(validate_non_empty_chars(" test123")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace(" test123") | ||
|
||
def test_whitespace_in_between(self): | ||
self.assertIsNone(validate_non_empty_chars("test 123")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace("test 123") | ||
|
||
def test_whitespace_only(self): | ||
with self.assertRaises(ValidationError): | ||
validate_non_empty_chars(" ") | ||
validate_whitespace(" ") | ||
|
||
def test_trailing_tab_character(self): | ||
self.assertIsNone(validate_non_empty_chars("test123\t")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace("test123\t") | ||
|
||
def test_leading_tab_character(self): | ||
self.assertIsNone(validate_non_empty_chars("\ttest123")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace("\ttest123") | ||
|
||
def test_tab_character_in_between(self): | ||
self.assertIsNone(validate_non_empty_chars("test\t123")) | ||
with self.assertRaises(ValidationError): | ||
validate_whitespace("test\t123") | ||
|
||
def test_tab_characters_only(self): | ||
with self.assertRaises(ValidationError): | ||
validate_non_empty_chars("\t\t") | ||
validate_whitespace("\t\t") | ||
|
||
def test_blank_value(self): | ||
with self.assertRaises(ValidationError): | ||
validate_non_empty_chars("") | ||
validate_whitespace("") |
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