-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix filters args + Add tests for filters
- Loading branch information
1 parent
f85f855
commit e453275
Showing
5 changed files
with
65 additions
and
7 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,51 @@ | ||
""" Test filters. """ | ||
from unittest import TestCase | ||
|
||
from baygon.filters import ( | ||
FilterIgnoreSpaces, | ||
FilterLowercase, | ||
FilterNone, | ||
FilterRegex, | ||
FilterReplace, | ||
Filters, | ||
FilterTrim, | ||
FilterUppercase, | ||
) | ||
|
||
|
||
class TestFilters(TestCase): | ||
def test_filter_uppercase(self): | ||
f = FilterUppercase() | ||
self.assertEqual(f('hello'), 'HELLO') | ||
|
||
def test_filter_lowercase(self): | ||
f = FilterLowercase() | ||
self.assertEqual(f('HELLO'), 'hello') | ||
|
||
def test_filter_trim(self): | ||
f = FilterTrim() | ||
self.assertEqual(f(' hello '), 'hello') | ||
|
||
def test_filter_none(self): | ||
f = FilterNone() | ||
self.assertEqual(f(' hello '), ' hello ') | ||
|
||
def test_filter_replace(self): | ||
f = FilterReplace('hello', 'bye') | ||
self.assertEqual(f('hello world'), 'bye world') | ||
|
||
def test_filter_regex(self): | ||
f = FilterRegex(r'h[el]+o', 'bye') | ||
self.assertEqual(f('hello world'), 'bye world') | ||
|
||
def test_filter_ignore_spaces(self): | ||
f = FilterIgnoreSpaces() | ||
self.assertEqual(f('hello world'), 'helloworld') | ||
|
||
def test_filter_multiple(self): | ||
f = Filters({ | ||
'ignorespaces': True, | ||
'uppercase': True, | ||
'replace': ['L', 'Z'] | ||
}) | ||
self.assertEqual(f('hello world'), 'HEZZOWORZD') |