forked from google/data-quality-monitor
-
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.
Change-Id: Ic0c21c03b5ada188b8e80a7063c6a3711d194a94
- Loading branch information
1 parent
bf95935
commit 8cde60f
Showing
9 changed files
with
74 additions
and
75 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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
from rules.text import contains_at_sign | ||
|
||
|
||
class ContainsAtSign(unittest.TestCase): | ||
class ContainsAtSignTest(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.rule_checker = contains_at_sign() | ||
|
@@ -29,10 +29,10 @@ def test_returns_callable(self): | |
self.assertTrue(callable(self.rule_checker)) | ||
|
||
def test_string_with_character(self): | ||
self.assertIsNotNone(self.rule_checker("@")) | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNotNone(self.rule_checker("john@@")) | ||
self.assertIsNone(self.rule_checker("@")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("john@@")) | ||
|
||
def test_string_without_character(self): | ||
self.assertIsNone(self.rule_checker("johndoe.com")) | ||
self.assertIsNone(self.rule_checker("")) | ||
self.assertIsNotNone(self.rule_checker("johndoe.com")) | ||
self.assertIsNotNone(self.rule_checker("")) |
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
from rules.text import is_email | ||
|
||
|
||
class IsEmail(unittest.TestCase): | ||
class IsEmailTest(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.rule_checker = is_email() | ||
|
@@ -30,69 +30,69 @@ def test_returns_callable(self): | |
|
||
def test_valid_emails(self): | ||
# standard email addresses | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
|
||
# dot seperated email name | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
|
||
# email with number | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
|
||
# email with capitals | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
|
||
# leading space | ||
self.assertIsNotNone(self.rule_checker(" [email protected]")) | ||
self.assertIsNone(self.rule_checker(" [email protected]")) | ||
|
||
# trailing space | ||
self.assertIsNotNone(self.rule_checker("[email protected] ")) | ||
self.assertIsNone(self.rule_checker("[email protected] ")) | ||
|
||
# email in random string | ||
self.assertIsNotNone( | ||
self.assertIsNone( | ||
self.rule_checker("asdfasdfsdf [email protected]")) | ||
|
||
def test_invalid_characters(self): | ||
# quotes | ||
self.assertIsNone(self.rule_checker("john\"@doe.com")) | ||
self.assertIsNone(self.rule_checker("john'@doe.com")) | ||
self.assertIsNone(self.rule_checker("john@doe\".com")) | ||
self.assertIsNone(self.rule_checker("john@do'e.com")) | ||
self.assertIsNotNone(self.rule_checker("john\"@doe.com")) | ||
self.assertIsNotNone(self.rule_checker("john'@doe.com")) | ||
self.assertIsNotNone(self.rule_checker("john@doe\".com")) | ||
self.assertIsNotNone(self.rule_checker("john@do'e.com")) | ||
|
||
# asterisk | ||
self.assertIsNone(self.rule_checker("john**@doe.com")) | ||
self.assertIsNone(self.rule_checker("john@do*e.com")) | ||
self.assertIsNotNone(self.rule_checker("john**@doe.com")) | ||
self.assertIsNotNone(self.rule_checker("john@do*e.com")) | ||
|
||
# backslash | ||
# self.assertIsNone(self.rule_checker("jo\[email protected]")) | ||
self.assertIsNone(self.rule_checker(r"john@do\e.com")) | ||
# self.assertIsNotNone(self.rule_checker("jo\[email protected]")) | ||
self.assertIsNotNone(self.rule_checker(r"john@do\e.com")) | ||
|
||
def test_invalid_email_structure(self): | ||
# missing address sign | ||
self.assertIsNone(self.rule_checker("john.com")) | ||
self.assertIsNotNone(self.rule_checker("john.com")) | ||
|
||
# double at sign | ||
self.assertIsNone(self.rule_checker("john@@com")) | ||
self.assertIsNotNone(self.rule_checker("john@@com")) | ||
|
||
# wrongly placed at sign | ||
self.assertIsNone(self.rule_checker("johndoe.co@m")) | ||
self.assertIsNotNone(self.rule_checker("johndoe.co@m")) | ||
|
||
# leading at sign | ||
self.assertIsNone(self.rule_checker("@john.com")) | ||
self.assertIsNotNone(self.rule_checker("@john.com")) | ||
|
||
# trailing at sign | ||
self.assertIsNone(self.rule_checker("john.com@")) | ||
self.assertIsNotNone(self.rule_checker("john.com@")) | ||
|
||
# missing dot | ||
self.assertIsNone(self.rule_checker("john@doecom")) | ||
self.assertIsNotNone(self.rule_checker("john@doecom")) | ||
|
||
# double dot in domain | ||
self.assertIsNone(self.rule_checker("[email protected]")) | ||
self.assertIsNotNone(self.rule_checker("[email protected]")) | ||
|
||
def test_invalid_input(self): | ||
# number string | ||
self.assertIsNone(self.rule_checker('252342')) | ||
self.assertIsNotNone(self.rule_checker('252342')) | ||
|
||
# character string | ||
self.assertIsNone(self.rule_checker('*#^$*(@($&')) | ||
self.assertIsNotNone(self.rule_checker('*#^$*(@($&')) |
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