Ejemplo n.º 1
0
    def clean_emails(self):
        """Clean up email field to only include symantically valid addresses"""
        addresses = clean_addresses(self.cleaned_data['emails'])

        if not addresses:
            raise ValidationError('No Valid Addresses Found')

        emails = ','.join([address[1] for address in addresses])
        return emails
Ejemplo n.º 2
0
 def test_valid_list(self):
     """Test where every address is valid"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [('Nick Cat', '*****@*****.**'),
                               ('Jordan', '*****@*****.**'),
                               ('Jack', '*****@*****.**'),
                               ('Grace', '*****@*****.**')])
Ejemplo n.º 3
0
    def clean_emails(self):
        """Clean up email field to only include symantically valid addresses"""
        addresses = clean_addresses(self.cleaned_data['emails'])

        if not addresses:
            raise ValidationError('No Valid Addresses Found')

        emails = ','.join([address[1] for address in addresses])
        return emails
Ejemplo n.º 4
0
 def test_lowercase_email_addresses(self):
     """Test that the function lowercases all addresses"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [('Nick Cat', u'*****@*****.**'),
                               ('Jordan', '*****@*****.**'),
                               ('Jack', '*****@*****.**'),
                               ('Grace', '*****@*****.**')])
Ejemplo n.º 5
0
 def test_valid_list(self):
     """Test where every address is valid"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [
         ('Nick Cat', '*****@*****.**'), ('Jordan', '*****@*****.**'),
         ('Jack', '*****@*****.**'), ('Grace', '*****@*****.**')
     ])
Ejemplo n.º 6
0
 def test_lowercase_email_addresses(self):
     """Test that the function lowercases all addresses"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [
         ('Nick Cat', u'*****@*****.**'), ('Jordan', '*****@*****.**'),
         ('Jack', '*****@*****.**'), ('Grace', '*****@*****.**')
     ])
Ejemplo n.º 7
0
    def clean_emails(self):
        """Clean up email field to only include symantically valid addresses"""
        emails = clean_addresses(self.data['emails'])

        if not len(emails):
            raise ValidationError('No Valid Addresses Found')

        email_string = [formataddr(entry) for entry in emails]

        return email_string
Ejemplo n.º 8
0
 def test_with_invalid_addresses(self):
     """Test where there are some invalid email addresses"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, tester@, Not An Email,'
               'Bad Address <@>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [('Nick Cat', '*****@*****.**'),
                               ('Jordan', '*****@*****.**'),
                               ('Jack', '*****@*****.**'),
                               ('Grace', '*****@*****.**')])
Ejemplo n.º 9
0
 def test_with_invalid_addresses(self):
     """Test where there are some invalid email addresses"""
     emails = ('Nick Cat <*****@*****.**>, Jordan <*****@*****.**>,'
               'Jack <*****@*****.**>, tester@, Not An Email,'
               'Bad Address <@>, Grace <*****@*****.**>')
     result = utils.clean_addresses(emails)
     self.assertEqual(result, [
         ('Nick Cat', '*****@*****.**'), ('Jordan', '*****@*****.**'),
         ('Jack', '*****@*****.**'), ('Grace', '*****@*****.**')
     ])
Ejemplo n.º 10
0
    def clean_emails(self):
        """Clean up email field to only include symantically valid addresses"""
        emails = clean_addresses(self.data['emails'])

        if not len(emails):
            raise ValidationError('No Valid Addresses Found')

        email_string = [formataddr(entry) for entry in emails]

        return email_string
Ejemplo n.º 11
0
 def test_empty_list(self):
     """Test where an empty string is passed to the function"""
     result = utils.clean_addresses('')
     self.assertEqual(result, [])
Ejemplo n.º 12
0
 def test_empty_list(self):
     """Test where an empty string is passed to the function"""
     result = utils.clean_addresses('')
     self.assertEqual(result, [])