Esempio n. 1
0
    def test_register_invalid(self):
        class TestNotification(object):
            pass

        with self.assertRaises(ValueError):
            registry.register(TestNotification)

        self.assertEqual(len(registry._registry), 4)
Esempio n. 2
0
    def test_register(self):
        class TestNotification(EmailNotification):
            pass

        registry.register(TestNotification)

        self.assertEqual(len(registry._registry), 2)

        registry.unregister(TestNotification)

        self.assertEqual(len(registry._registry), 1)
Esempio n. 3
0
    def test_register(self):
        class TestNotification(EmailNotification):
            pass

        registry.register(TestNotification)

        self.assertEqual(len(registry._registry), 5)

        registry.unregister(TestNotification)

        self.assertEqual(len(registry._registry), 4)
Esempio n. 4
0
    def get_attachments(self):
        # this returns two attachments, one a text file, the other an inline attachment that can be referred to in a
        # template using cid: notation
        fp = open('tests/python.jpeg', 'rb')
        img = MIMEImage(fp.read())
        img.add_header('Content-ID', '<{}>'.format('python.jpg'))

        raw_data = 'Some Report Data'

        return [
            ('Report.txt', raw_data, 'text/plain'),
            img,
        ]

registry.register(MyNotification)


class MyOtherNotification(EmailNotification):
    context = {'hello': 'world'}
    template_name = 'hello_world'
    to_emails = ['*****@*****.**']

registry.register(MyOtherNotification)


class MyTwilioNotification(TwilioTextNotification):
    context = {'hello': 'world'}
    template_name = 'hello_world'
    to_emails = ['*****@*****.**']
Esempio n. 5
0
from herald.base import EmailNotification
from herald import registry


class MyNotification(EmailNotification):
    context = {'hello': 'world'}
    template_name = 'hello_world'
    to_emails = ['*****@*****.**']

registry.register(MyNotification)