Esempio n. 1
0
    def test_daily_account_summary(self):
        msg_helper = GoMessageHelper(vumi_helper=self.vumi_helper)
        conv = self.user_helper.create_conversation(
            u'bulk_message', name=u'Test Conversation', started=True)
        self.user_helper.contact_store.new_contact(
            name=u'Contact', surname=u'One', msisdn=u"+27761234567")
        self.user_helper.contact_store.new_contact(
            name=u'Contact', surname=u'Two', msisdn=u"+27761234567")

        msgs = msg_helper.add_inbound_to_conv(conv, 5)
        msg_helper.add_replies_to_conv(conv, msgs)
        # create a second conversation to test sorting
        self.user_helper.create_conversation(u'bulk_message')

        django_user = self.user_helper.get_django_user()

        # schedule the task
        send_user_account_summary(django_user)

        [email] = mail.outbox
        self.assertEqual(email.subject, 'Vumi Go Account Summary')
        self.assertEqual(email.from_email, settings.DEFAULT_FROM_EMAIL)
        self.assertEqual(email.recipients(), [django_user.email])
        self.assertTrue('number of contacts: 2' in email.body)
        self.assertTrue('number of unique contacts by contact number: 1'
                            in email.body)
        self.assertTrue('number of messages sent: 5' in email.body)
        self.assertTrue('number of messages received: 5' in email.body)
        self.assertTrue('Group Message' in email.body)
        self.assertTrue('Test Conversation' in email.body)
        self.assertTrue('Sent: 5 to 5 uniques.' in email.body)
        self.assertTrue('Received: 5 from 5 uniques.' in email.body)
        self.assertTrue('"Group Message" Sent: 5' in email.body)
        self.assertTrue('"Group Message" Received: 5' in email.body)
Esempio n. 2
0
def send_scheduled_account_summary(interval):
    users = get_user_model().objects.all()
    for user in users:
        user_account = user.get_profile().get_user_account()
        if user_account.email_summary == interval:
            send_user_account_summary(user)
Esempio n. 3
0
def send_scheduled_account_summary(interval):
    users = get_user_model().objects.all()
    for user in users:
        user_account = user.get_profile().get_user_account()
        if user_account.email_summary == interval:
            send_user_account_summary(user)