Exemple #1
0
    def test_should_return_false_for_non_string_objects(self):
        # noinspection PyTypeChecker
        self.assertFalse(is_email(None))

        # noinspection PyTypeChecker
        self.assertFalse(is_email(False))

        # noinspection PyTypeChecker
        self.assertFalse(is_email(0))

        # noinspection PyTypeChecker
        self.assertFalse(is_email([]))

        # noinspection PyTypeChecker
        self.assertFalse(is_email({'a': 1}))
Exemple #2
0
 def test_should_accept_valid_emails(self):
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
     self.assertTrue(is_email('*****@*****.**'))
Exemple #3
0
    def test_does_not_try_to_format_email(self):
        email = '*****@*****.**'
        self.assertTrue(is_email(email))
        self.assertEqual(email, prettify(email))
        self.assertEqual('This is the email: {}'.format(email),
                         prettify('this is the email : {}'.format(email)))

        multiple_emails = [
            '*****@*****.**', '*****@*****.**', '*****@*****.**'
        ]
        self.assertEqual(prettify(','.join(multiple_emails)),
                         ', '.join(multiple_emails))
Exemple #4
0
 def test_head_cannot_end_with_period(self):
     self.assertFalse(is_email('*****@*****.**'))
Exemple #5
0
 def test_domain_extension_should_be_letters_only_from_2_to_4_chars(self):
     self.assertFalse(is_email('[email protected]'))
     self.assertFalse(is_email('[email protected]'))
     self.assertFalse(is_email('me@foo.!!'))
     self.assertFalse(is_email('me@foo.___'))
     self.assertFalse(is_email('*****@*****.**'))
Exemple #6
0
 def test_tail_length_is_respected(self):
     # max tail size is 255
     invalid_email = 'a@{}.com'.format(255 * 'x')
     self.assertFalse(is_email(invalid_email))
Exemple #7
0
 def test_plus_is_invalid_char_in_tail(self):
     self.assertFalse(is_email('mymail@foo+bar.com'))
Exemple #8
0
 def test_domain_cannot_be_single_char(self):
     self.assertFalse(is_email('*****@*****.**'))
Exemple #9
0
 def test_max_email_length_is_respected(self):
     invalid_email = ('a' * 320) + '@gmail.com'
     self.assertFalse(is_email(invalid_email))
Exemple #10
0
 def test_with_escape_multiple_at_are_accepted(self):
     self.assertTrue(is_email('Abc\\@[email protected]'))
Exemple #11
0
 def test_tail_cannot_be_uppercase(self):
     self.assertFalse(is_email('*****@*****.**'))
Exemple #12
0
 def test_head_quotes_must_be_correct(self):
     self.assertFalse(is_email('"*****@*****.**'))
     self.assertFalse(is_email('no"*****@*****.**'))
     self.assertFalse(is_email('nope"@gmail.com'))
     self.assertFalse(is_email('""@gmail.com'))
     self.assertFalse(is_email('"no"pe"@gmail.com'))
Exemple #13
0
 def test_with_quoted_string_multiple_at_are_accepted(self):
     self.assertTrue(is_email('"Abc@def"@example.com'))
Exemple #14
0
 def test_head_can_be_quoted(self):
     self.assertTrue(is_email('"foo"@example.com'))
Exemple #15
0
 def test_empty_spaces_are_allowed_only_if_escaped(self):
     self.assertFalse(is_email('my [email protected]'))
     self.assertTrue(is_email('my\\ [email protected]'))
     self.assertTrue(is_email('"my mail"@gmail.com'))
Exemple #16
0
 def test_head_cannot_have_multiple_consecutive_periods(self):
     self.assertFalse(is_email('*****@*****.**'))
     self.assertFalse(is_email('*****@*****.**'))
Exemple #17
0
 def test_head_cannot_contain_suqare_brackets(self):
     self.assertFalse(is_email('[[email protected]'))
     self.assertFalse(is_email('my][email protected]'))
Exemple #18
0
 def test_head_can_have_self_escape(self):
     self.assertTrue(is_email('Joe.\\\\[email protected]'))
Exemple #19
0
 def test_tail_cannot_contain_bad_signs(self):
     self.assertFalse(is_email('me@#foo#.com'))
     self.assertFalse(is_email('me@foo!.com'))
     self.assertFalse(is_email('someone@[foo].com'))
Exemple #20
0
 def test_string_cannot_be_empty(self):
     self.assertFalse(is_email(''))
     self.assertFalse(is_email(' '))
Exemple #21
0
 def test_tail_cannot_contain_dots_sequence(self):
     self.assertFalse(is_email('*****@*****.**'))
     self.assertFalse(is_email('*****@*****.**'))
Exemple #22
0
 def test_tail_is_required(self):
     self.assertFalse(is_email('name@'))
Exemple #23
0
 def test_curly_braces_are_valid_char_in_head(self):
     self.assertTrue(is_email('my{[email protected]'))
     self.assertTrue(is_email('my}[email protected]'))
     self.assertTrue(is_email('{mymail}@gmail.com'))
Exemple #24
0
 def test_head_is_required(self):
     self.assertFalse(is_email('@foo.com'))
Exemple #25
0
 def test_head_length_is_respected(self):
     # max head size is 64
     invalid_email = ('a' * 65) + '@gmail.com'
     self.assertFalse(is_email(invalid_email))
Exemple #26
0
 def test_tilde_is_invalid_char_in_tail(self):
     self.assertFalse(is_email('mymail@gma~il.com'))
Exemple #27
0
 def test_plus_is_valid_char_in_head(self):
     self.assertTrue(is_email('*****@*****.**'))
Exemple #28
0
 def test_domain_extension_is_required(self):
     self.assertFalse(is_email('name@site'))
     self.assertFalse(is_email('name@site.'))
Exemple #29
0
 def test_at_sign_is_required(self):
     self.assertFalse(is_email('name.site.com'))
Exemple #30
0
 def test_head_cannot_start_with_period(self):
     self.assertFalse(is_email('*****@*****.**'))