-
-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pre-commit-ci-update-config
- Loading branch information
Showing
5 changed files
with
45 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.test import SimpleTestCase | ||
|
||
from push_notifications.fields import HexadecimalField | ||
|
||
|
||
class HexadecimalFieldTestCase(SimpleTestCase): | ||
_INVALID_HEX_VALUES = [ | ||
"foobar", | ||
"GLUTEN", | ||
"HeLLo WoRLd", | ||
"international", | ||
"°!#€%&/()[]{}=?", | ||
"0x", | ||
] | ||
|
||
_VALID_HEX_VALUES = { | ||
"babe": "babe", | ||
"BEEF": "BEEF", | ||
" \nfeed \t": "feed", | ||
"0x012345789abcdef": "0x012345789abcdef", | ||
"012345789aBcDeF": "012345789aBcDeF", | ||
} | ||
|
||
def test_clean_invalid_values(self): | ||
"""Passing invalid values raises ValidationError.""" | ||
f = HexadecimalField() | ||
for invalid in self._INVALID_HEX_VALUES: | ||
self.assertRaisesMessage( | ||
ValidationError, | ||
"'Enter a valid hexadecimal number'", | ||
f.clean, | ||
invalid, | ||
) | ||
|
||
def test_clean_valid_values(self): | ||
"""Passing valid values returns the expected output.""" | ||
f = HexadecimalField() | ||
for valid, expected in self._VALID_HEX_VALUES.items(): | ||
self.assertEqual(expected, f.clean(valid)) |
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,5 +1,5 @@ | ||
[tox] | ||
skipsdist = True | ||
skipsdist = False | ||
usedevelop = true | ||
envlist = | ||
py{36,37,38,39}-dj{22,32} | ||
|