예제 #1
0
 def test_send_assigned_offer_email(
         self,
         greeting,
         closing,
         tokens,
         side_effect,
         mock_sailthru_task,
 ):
     """ Test that the offer assignment email message is sent to async task. """
     email_subject = settings.OFFER_ASSIGNMENT_EMAIL_SUBJECT
     mock_sailthru_task.delay.side_effect = side_effect
     send_assigned_offer_email(
         greeting,
         closing,
         tokens.get('offer_assignment_id'),
         tokens.get('learner_email'),
         tokens.get('code'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'),
     )
     mock_sailthru_task.delay.assert_called_once_with(
         tokens.get('learner_email'),
         tokens.get('offer_assignment_id'),
         email_subject,
         mock.ANY
     )
예제 #2
0
 def test_send_assigned_offer_email(
     self,
     tokens,
     side_effect,
     mock_sailthru_task,
 ):
     """ Test that the offer assignment email message is correctly formatted with correct call to async task. """
     email_subject = settings.OFFER_ASSIGNMENT_EMAIL_DEFAULT_SUBJECT
     mock_sailthru_task.delay.side_effect = side_effect
     template = settings.OFFER_ASSIGNMENT_EMAIL_DEFAULT_TEMPLATE
     send_assigned_offer_email(
         template,
         tokens.get('offer_assignment_id'),
         tokens.get('learner_email'),
         tokens.get('code'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'),
     )
     expected_email_body = template.format(
         REDEMPTIONS_REMAINING=tokens.get('redemptions_remaining'),
         USER_EMAIL=tokens.get('learner_email'),
         CODE=tokens.get('code'),
         EXPIRATION_DATE=tokens.get('code_expiration_date'))
     mock_sailthru_task.delay.assert_called_once_with(
         tokens.get('learner_email'), tokens.get('offer_assignment_id'),
         email_subject, expected_email_body)
예제 #3
0
 def test_send_assigned_offer_email(
     self,
     subject,
     greeting,
     closing,
     tokens,
     side_effect,
     base_enterprise_url,
     mock_sailthru_task,
 ):
     """ Test that the offer assignment email message is sent to async task. """
     mock_sailthru_task.delay.side_effect = side_effect
     send_assigned_offer_email(
         subject,
         greeting,
         closing,
         tokens.get('offer_assignment_id'),
         tokens.get('learner_email'),
         tokens.get('code'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'),
         base_enterprise_url,
     )
     mock_sailthru_task.delay.assert_called_once_with(
         tokens.get('learner_email'),
         tokens.get('offer_assignment_id'),
         subject,
         mock.ANY,
         None,
         base_enterprise_url,
     )
예제 #4
0
    def test_send_assigned_offer_email_without_base_ent_url(
            self, mock_sailthru_task):
        send_assigned_offer_email("You have mail", "you", "KTHXBAI", 42,
                                  "*****@*****.**", 'BearsOnly', 1,
                                  '2020-12-19', 'sender alias')

        mock_sailthru_task.delay.assert_called_once_with(
            "*****@*****.**",
            42,
            "You have mail",
            mock.ANY,
            'sender alias',
            None,
            '',
        )
예제 #5
0
 def test_send_assigned_offer_email(
         self,
         tokens,
         side_effect,
         returns,
         mock_sailthru_task,
 ):
     email_subject = settings.OFFER_ASSIGNMENT_EMAIL_DEFAULT_SUBJECT
     mock_sailthru_task.delay.side_effect = side_effect
     template = settings.OFFER_ASSIGNMENT_EMAIL_DEFAULT_TEMPLATE
     status = send_assigned_offer_email(
         template,
         tokens.get('offer_assignment_id'),
         tokens.get('learner_email'),
         tokens.get('code'),
         tokens.get('enrollment_url'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'),
     )
     expected_email_body = template.format(
         REDEMPTIONS_REMAINING=tokens.get('redemptions_remaining'),
         USER_EMAIL=tokens.get('learner_email'),
         ENROLLMENT_URL=tokens.get('enrollment_url'),
         CODE=tokens.get('code'),
         EXPIRATION_DATE=tokens.get('code_expiration_date')
     )
     mock_sailthru_task.delay.assert_called_once_with(
         tokens.get('learner_email'),
         tokens.get('offer_assignment_id'),
         email_subject, expected_email_body)
     self.assertEqual(status, returns)
예제 #6
0
 def test_send_assigned_offer_email_via_braze(
     self,
     subject,
     greeting,
     closing,
     tokens,
     side_effect,
     sender_alias,
     base_enterprise_url,
     search_url,
     mock_sailthru_task,
 ):
     """ Test that the offer assignment email message is sent to async task. """
     switch, __ = Switch.objects.get_or_create(name=ENABLE_BRAZE)
     switch.active = True
     switch.save()
     mock_sailthru_task.delay.side_effect = side_effect
     send_assigned_offer_email(
         subject,
         greeting,
         closing,
         tokens.get('offer_assignment_id'),
         tokens.get('learner_email'),
         tokens.get('code'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'),
         sender_alias,
         base_enterprise_url,
     )
     email_body = format_assigned_offer_email(
         greeting, closing, tokens.get('learner_email'), tokens.get('code'),
         tokens.get('redemptions_remaining'),
         tokens.get('code_expiration_date'), search_url)
     mock_sailthru_task.delay.assert_called_once_with(
         tokens.get('learner_email'),
         tokens.get('offer_assignment_id'),
         subject,
         email_body,
         sender_alias,
         None,
         base_enterprise_url,
     )
예제 #7
0
    def test_send_assigned_offer_email_without_base_ent_url_and_attachments(
            self, mock_email_task):
        send_assigned_offer_email(
            "You have mail",
            "you",
            "KTHXBAI",
            42,
            "*****@*****.**",
            'BearsOnly',
            1,
            '2020-12-19',
            'sender alias',
            '*****@*****.**',
        )

        mock_email_task.delay.assert_called_once_with("*****@*****.**",
                                                      42,
                                                      "You have mail",
                                                      mock.ANY,
                                                      'sender alias',
                                                      '*****@*****.**',
                                                      attachments=[],
                                                      base_enterprise_url='')