Exemplo n.º 1
0
 def build_from_address(self):
     str_addr = '{} <{}@{}>'.format(
         self._config['human_name'],
         self._config['from_name'],
         self._config['domain']
     )
     return Recipient.from_string(str_addr, 'from')
Exemplo n.º 2
0
    def test_smoke_build_email(self):
        recps = [Recipient.from_string('*****@*****.**', 'to')],
        invalid_mail = "asdasda"

        self.assertRaises(  # Invalid recipient
            InvalidRecipientError, build_email, [object()], None, None)
        self.assertRaises(  # Invalid replyto
            InvalidRecipientError,
            build_email,
            recps,
            None,
            None,
            replyto=invalid_mail)
        self.assertRaises(  # Invalid from
            InvalidRecipientError,
            build_email,
            recps,
            None,
            None,
            from_=invalid_mail)
Exemplo n.º 3
0
    def setUp(self):
        self.registered_providers = REGISTERED_PROVIDERS

        self.recps = build_recipients({
            'to':
            "a b <*****@*****.**>",
            'cc': ["c d <*****@*****.**>", "*****@*****.**", "           [email protected]"],
            'bcc':
            "hey <*****@*****.**"  # should pass
        })
        self.from_ = Recipient.from_string("unittest <noreply@unitest", 'from')

        complete = Email(subject="a",
                         text='hey',
                         html="<p>hey</p>",
                         replyto="*****@*****.**")
        complete.add_recipients(self.recps)
        complete.from_ = self.from_

        self.emails = [Email(), complete]
        self.key_config = {'user': '******', 'key': 'blah'}
Exemplo n.º 4
0
    def setUp(self):
        self.registered_providers = REGISTERED_PROVIDERS

        self.recps = build_recipients({
            'to': "a b <*****@*****.**>",
            'cc': ["c d <*****@*****.**>", "*****@*****.**", "           [email protected]"],
            'bcc': "hey <*****@*****.**"  # should pass
        })
        self.from_ = Recipient.from_string("unittest <noreply@unitest", 'from')

        complete = Email(
            subject="a",
            text='hey',
            html="<p>hey</p>",
            replyto="*****@*****.**"
        )
        complete.add_recipients(self.recps)
        complete.from_ = self.from_

        self.emails = [
            Email(),
            complete
        ]
        self.key_config = {'user': '******', 'key': 'blah'}
Exemplo n.º 5
0
 def setUp(self):
     self.bad_recipients = [None, [], 1, object(), 'blah']
     self.recipients = [Recipient('*****@*****.**', 'My Name', 'to')]
     self.bad_subject = ['a' * 90]
     self.subject = ['bonjour', 'a']
     self.bodies = [None, '', 'I talk a lot' * 42]
Exemplo n.º 6
0
 def test_smoke(self):
     for e in self.valid_emails:
         for n in self.display_names:
             r = Recipient(e, n, self.types[0])
             self.assertEqual([r.email, r.display_name], [e, n])
Exemplo n.º 7
0
 def test_bad_types(self):
     for t in self.bad_types:
         r = Recipient(self.valid_emails[0], None, t)
         self.assertRaises(InvalidRecipientError, r.validate)
Exemplo n.º 8
0
 def test_types(self):
     for t in self.types:
         r = Recipient(self.valid_emails[0], None, t)
         r.validate()
Exemplo n.º 9
0
 def test_valid_email_recipient(self):
     for e in self.valid_emails:
         r = Recipient(e, None, self.types[0])
         self.assertEqual(r.email, e)
         self.assertEqual(r.validate(), True)
Exemplo n.º 10
0
 def test_bad_email_recipient(self):
     for e in self.bad_emails:
         r = Recipient(e, None, self.types[0])
         self.assertRaises(InvalidRecipientError, r.validate)