Esempio n. 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}))
Esempio n. 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('*****@*****.**'))
Esempio n. 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))
Esempio n. 4
0
 def test_head_cannot_end_with_period(self):
     self.assertFalse(is_email('*****@*****.**'))
Esempio n. 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('*****@*****.**'))
Esempio n. 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))
Esempio n. 7
0
 def test_plus_is_invalid_char_in_tail(self):
     self.assertFalse(is_email('mymail@foo+bar.com'))
Esempio n. 8
0
 def test_domain_cannot_be_single_char(self):
     self.assertFalse(is_email('*****@*****.**'))
Esempio n. 9
0
 def test_max_email_length_is_respected(self):
     invalid_email = ('a' * 320) + '@gmail.com'
     self.assertFalse(is_email(invalid_email))
Esempio n. 10
0
 def test_with_escape_multiple_at_are_accepted(self):
     self.assertTrue(is_email('Abc\\@[email protected]'))
Esempio n. 11
0
 def test_tail_cannot_be_uppercase(self):
     self.assertFalse(is_email('*****@*****.**'))
Esempio n. 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'))
Esempio n. 13
0
 def test_with_quoted_string_multiple_at_are_accepted(self):
     self.assertTrue(is_email('"Abc@def"@example.com'))
Esempio n. 14
0
 def test_head_can_be_quoted(self):
     self.assertTrue(is_email('"foo"@example.com'))
Esempio n. 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'))
Esempio n. 16
0
 def test_head_cannot_have_multiple_consecutive_periods(self):
     self.assertFalse(is_email('*****@*****.**'))
     self.assertFalse(is_email('*****@*****.**'))
Esempio n. 17
0
 def test_head_cannot_contain_suqare_brackets(self):
     self.assertFalse(is_email('[[email protected]'))
     self.assertFalse(is_email('my][email protected]'))
Esempio n. 18
0
 def test_head_can_have_self_escape(self):
     self.assertTrue(is_email('Joe.\\\\[email protected]'))
Esempio n. 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'))
Esempio n. 20
0
 def test_string_cannot_be_empty(self):
     self.assertFalse(is_email(''))
     self.assertFalse(is_email(' '))
Esempio n. 21
0
 def test_tail_cannot_contain_dots_sequence(self):
     self.assertFalse(is_email('*****@*****.**'))
     self.assertFalse(is_email('*****@*****.**'))
Esempio n. 22
0
 def test_tail_is_required(self):
     self.assertFalse(is_email('name@'))
Esempio n. 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'))
Esempio n. 24
0
 def test_head_is_required(self):
     self.assertFalse(is_email('@foo.com'))
Esempio n. 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))
Esempio n. 26
0
 def test_tilde_is_invalid_char_in_tail(self):
     self.assertFalse(is_email('mymail@gma~il.com'))
Esempio n. 27
0
 def test_plus_is_valid_char_in_head(self):
     self.assertTrue(is_email('*****@*****.**'))
Esempio n. 28
0
 def test_domain_extension_is_required(self):
     self.assertFalse(is_email('name@site'))
     self.assertFalse(is_email('name@site.'))
Esempio n. 29
0
 def test_at_sign_is_required(self):
     self.assertFalse(is_email('name.site.com'))
Esempio n. 30
0
 def test_head_cannot_start_with_period(self):
     self.assertFalse(is_email('*****@*****.**'))