Beispiel #1
0
class TestSendGrid(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        sendgrid = SendGrid(username=os.environ.get('SENDGRID_USER'),
                            password=os.environ.get('SENDGRID_PASS'))
        self.email_lover.providers.append(sendgrid)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove SendGrid Test"

    def test_unsubscribes(self):
        results = self.email_lover.unsubscribes()
        self.assertNotEqual(len(results), 0)

    def test_send_html(self):
        result = self.email_lover.send({
            'subject':
            self.subject,
            'from':
            self.from_email,
            'to': [(self.to_email, '')],
            'text':
            'EmailLove sendgrid text message',
            'html':
            '<b>EmailLove</b> sendgrid html <em>message</em>',
        })
        self.assertTrue(result)

    def test_send_text(self):
        result = self.email_lover.send({
            'subject':
            self.subject,
            'from':
            self.from_email,
            'to': [(self.to_email, '')],
            'text':
            'EmailLove sendgrid text message',
        })
        self.assertTrue(result)

    def test_send_attachment(self):
        f = open("/tmp/testdoc.txt", "w+")
        f.write("This is a test document for emaillove.")
        f.close()

        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email,
            'to': [(self.to_email, '')],
            'text': 'EmailLove sendgrid text message',
            'html': '<b>EmailLove</b> sendgrid attachment <em>message</em>',
            'attachments': {
                'testdoc2.txt': '/tmp/testdoc.txt',
            }
        })
        self.assertTrue(result)
Beispiel #2
0
class TestMailGun(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        mailgun = MailGun(api_key=os.environ.get('MAILGUN_APIKEY'),
                          domain=os.environ.get('MAILGUN_DOMAIN'))
        self.email_lover.providers.append(mailgun)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove Mailgun Test"

    def test_send_html(self):
        result = self.email_lover.send({
            'subject':
            self.subject,
            'from':
            self.from_email,
            'to': [(self.to_email, '')],
            'text':
            'EmailLove mailgun text message',
            'html':
            '<b>EmailLove</b> mailgun html <em>message</em>',
        })
        self.assertTrue(result)

    def test_send_text(self):
        result = self.email_lover.send({
            'subject':
            self.subject,
            'from':
            self.from_email,
            'to': [(self.to_email, '')],
            'text':
            'EmailLove mailgun text message',
        })
        self.assertTrue(result)

    def test_send_attachment(self):
        f = open("/tmp/testdoc.txt", "w+")
        f.write("This is a test document for emaillove.")
        f.close()

        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email,
            'to': [(self.to_email, '')],
            'text': 'EmailLove mailgun text message',
            'html': '<b>EmailLove</b> mailgun attachment <em>message</em>',
            'attachments': {
                'testdoc.txt': '/tmp/testdoc.txt'
            }
        })
        self.assertTrue(result)
class TestDummySend(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        self.test_message = {'subject': 'subject'}

    def test_dummy_send(self):
        dummy = DummyProvider()
        mailgun = MailGun()
        self.email_lover.providers.append(dummy)
        self.email_lover.providers.append(mailgun)
        self.email_lover.send(self.test_message)
class TestSendGrid(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        sendgrid = SendGrid(username=os.environ.get('SENDGRID_USER'),
                            password=os.environ.get('SENDGRID_PASS'))
        self.email_lover.providers.append(sendgrid)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove SendGrid Test"

    def test_unsubscribes(self):
        results = self.email_lover.unsubscribes()
        self.assertNotEqual(len(results), 0)

    def test_send_html(self):
        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email,'')],
            'text': 'EmailLove sendgrid text message',
            'html': '<b>EmailLove</b> sendgrid html <em>message</em>',
        })
        self.assertTrue(result)

    def test_send_text(self):
        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email,'')],
            'text': 'EmailLove sendgrid text message',
        })
        self.assertTrue(result)

    def test_send_attachment(self):
        f = open("/tmp/testdoc.txt", "w+")
        f.write("This is a test document for emaillove.")
        f.close()

        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email, '')],
            'text': 'EmailLove sendgrid text message',
            'html': '<b>EmailLove</b> sendgrid attachment <em>message</em>',
            'attachments':{
                'testdoc2.txt': '/tmp/testdoc.txt',
            }
        })
        self.assertTrue(result)
Beispiel #5
0
    def setUp(self):
        self.email_lover = EmailLove()
        sendgrid = SendGrid(username=os.environ.get('SENDGRID_USER'),
                            password=os.environ.get('SENDGRID_PASS'))
        self.email_lover.providers.append(sendgrid)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove SendGrid Test"
Beispiel #6
0
    def setUp(self):
        self.email_lover = EmailLove()
        mailgun = MailGun(api_key=os.environ.get('MAILGUN_APIKEY'),
                          domain=os.environ.get('MAILGUN_DOMAIN'))
        self.email_lover.providers.append(mailgun)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove Mailgun Test"
class TestDummySend(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        self.test_message = {'subject': 'subject'}

    def test_sending_no_provider(self):
        with self.assertRaises(NoCurrentProvider):
              self.email_lover.send(self.test_message)

    def test_dummy_send(self):
        dummy = DummyProvider()
        self.email_lover.providers.append(dummy)
        self.email_lover.send(self.test_message)
Beispiel #8
0
class TestDummySend(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        self.test_message = {'subject': 'subject'}

    def test_sending_no_provider(self):
        with self.assertRaises(NoCurrentProvider):
            self.email_lover.send(self.test_message)

    def test_dummy_send(self):
        dummy = DummyProvider()
        self.email_lover.providers.append(dummy)
        self.email_lover.send(self.test_message)
Beispiel #9
0
class TestMailGun(unittest.TestCase):
    def setUp(self):
        self.email_lover = EmailLove()
        mailgun = MailGun(api_key=os.environ.get('MAILGUN_APIKEY'),
                          domain=os.environ.get('MAILGUN_DOMAIN'))
        self.email_lover.providers.append(mailgun)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove Mailgun Test"

    def test_send_html(self):
        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email, '')],
            'text': 'EmailLove mailgun text message',
            'html': '<b>EmailLove</b> mailgun html <em>message</em>',
        })
        self.assertTrue(result)

    def test_send_text(self):
        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email, '')],
            'text': 'EmailLove mailgun text message',
        })
        self.assertTrue(result)

    def test_send_attachment(self):
        f = open("/tmp/testdoc.txt", "w+")
        f.write("This is a test document for emaillove.")
        f.close()

        result = self.email_lover.send({
            'subject': self.subject,
            'from': self.from_email, 
            'to': [(self.to_email, '')],
            'text': 'EmailLove mailgun text message',
            'html': '<b>EmailLove</b> mailgun attachment <em>message</em>',
            'attachments':{
                'testdoc.txt': '/tmp/testdoc.txt' 
            }
        })
        self.assertTrue(result)
Beispiel #10
0
    def setUp(self):
        self.email_lover = EmailLove()
        sendgrid = SendGrid(username=os.environ.get('SENDGRID_USER'),
                            password=os.environ.get('SENDGRID_PASS'))
        self.email_lover.providers.append(sendgrid)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove SendGrid Test"
Beispiel #11
0
    def setUp(self):
        self.email_lover = EmailLove()
        mailgun = MailGun(api_key=os.environ.get('MAILGUN_APIKEY'),
                          domain=os.environ.get('MAILGUN_DOMAIN'))
        self.email_lover.providers.append(mailgun)

        self.from_email = os.environ.get('EMAILLOVE_FROM')
        self.to_email = os.environ.get('EMAILLOVE_TO')
        if self.to_email is None or self.from_email is None:
            raise RuntimeError("Please set from/to env variables")

        self.subject = "EmailLove Mailgun Test"
 def setUp(self):
     self.email_lover = EmailLove()
     self.test_message = {'subject': 'subject'}
Beispiel #13
0
 def setUp(self):
     self.email_lover = EmailLove()
     self.test_message = {'subject': 'subject'}