예제 #1
0
 def test_existing_user_interested(self):
     """Successful submission of the form for existing newsletter user."""
     email = '*****@*****.**'
     token = 'the dudes token, man'
     self.get_user_data.return_value = {
         'status': 'ok',
         'format': 'T',
         'token': token,
         'newsletters': ['about-mozilla', 'mozilla-and-you', 'get-involved'],
     }
     tasks.update_get_involved('bowling', 'en', 'Walter', email,
                               'US', 'T', 'Y', 'It really tied the room together.', None)
     self.apply_updates.assert_has_calls([
         call(settings.EXACTTARGET_DATA, {
             'EMAIL_ADDRESS_': '*****@*****.**',
             'MODIFIED_DATE_': ANY,
             'LANGUAGE_ISO2': 'en',
             'COUNTRY_': 'US',
             'TOKEN': token,
             'GET_INVOLVED_FLG': 'Y',
         }),
         call(settings.EXACTTARGET_INTERESTS, {
             'TOKEN': token,
             'INTEREST': 'bowling',
         }),
     ])
     self.send_message.delay.assert_called_with('en_welcome_bowling_T', email, token, 'T')
     # not called because 'about-mozilla' already in newsletters
     self.assertFalse(self.send_welcomes.called)
     self.interest.notify_stewards.assert_called_with('Walter', email, 'en',
                                                      'It really tied the room together.')
예제 #2
0
 def test_new_user_interested_no_sub(self):
     """Successful submission of the form for new user without newsletter subscription."""
     email = '*****@*****.**'
     self.get_user_data.return_value = None
     tasks.update_get_involved('bowling', 'en', 'Walter', email,
                               'US', 'H', False, 'It really tied the room together.', None)
     token = ANY
     self.apply_updates.assert_has_calls([
         call(settings.EXACTTARGET_DATA, {
             'EMAIL_ADDRESS_': email,
             'MODIFIED_DATE_': ANY,
             'LANGUAGE_ISO2': 'en',
             'COUNTRY_': 'US',
             'TOKEN': token,
             'EMAIL_FORMAT_': 'H',
             'GET_INVOLVED_FLG': 'Y',
             'GET_INVOLVED_DATE': ANY,
         }),
         call(settings.EXACTTARGET_INTERESTS, {
             'TOKEN': token,
             'INTEREST': 'bowling',
         }),
     ])
     self.send_message.delay.assert_called_with('en_welcome_bowling', email, token, 'H')
     self.assertFalse(self.send_welcomes.called)
     self.interest.notify_stewards.assert_called_with('Walter', email, 'en',
                                                      'It really tied the room together.')
예제 #3
0
 def test_new_user_interested(self):
     """Successful submission of the form for new user."""
     email = '*****@*****.**'
     self.get_user_data.return_value = None
     tasks.update_get_involved('bowling', 'en', 'Walter', email,
                               'US', 'T', 'Y', 'It really tied the room together.', None)
     self.apply_updates.assert_has_calls([
         call(settings.EXACTTARGET_DATA, {
             'EMAIL_ADDRESS_': email,
             'MODIFIED_DATE_': ANY,
             'LANGUAGE_ISO2': 'en',
             'COUNTRY_': 'US',
             'TOKEN': ANY,
             'EMAIL_FORMAT_': 'T',
             'ABOUT_MOZILLA_FLG': 'Y',
             'ABOUT_MOZILLA_DATE': ANY,
             'GET_INVOLVED_FLG': 'Y',
             'GET_INVOLVED_DATE': ANY,
         }),
         call(settings.EXACTTARGET_INTERESTS, {
             'TOKEN': ANY,
             'INTEREST': 'bowling',
         }),
     ])
     self.send_message.delay.assert_called_with('en_welcome_bowling_T', email, ANY, 'T')
     self.send_welcomes.assert_called_once_with({
         'email': email,
         'token': ANY,
         'lang': 'en',
     }, ['about-mozilla'], 'T')
     self.interest.notify_stewards.assert_called_with('Walter', email, 'en',
                                                      'It really tied the room together.')
예제 #4
0
 def test_new_user_interested_no_sub(self):
     """Successful submission of the form for new user without newsletter subscription."""
     email = "*****@*****.**"
     self.get_user_data.return_value = None
     tasks.update_get_involved(
         "bowling", "en", "Walter", email, "US", "H", False, "It really tied the room together.", None
     )
     token = models.Subscriber.objects.get(email=email).token
     self.apply_updates.assert_has_calls(
         [
             call(
                 settings.EXACTTARGET_DATA,
                 {
                     "EMAIL_ADDRESS_": email,
                     "MODIFIED_DATE_": ANY,
                     "LANGUAGE_ISO2": "en",
                     "COUNTRY_": "US",
                     "TOKEN": token,
                     "EMAIL_FORMAT_": "H",
                     "GET_INVOLVED_FLG": "Y",
                     "GET_INVOLVED_DATE": ANY,
                 },
             ),
             call(settings.EXACTTARGET_INTERESTS, {"TOKEN": token, "INTEREST": "bowling"}),
         ]
     )
     self.send_message.delay.assert_called_with("en_welcome_bowling", email, token, "H")
     self.assertFalse(self.send_welcomes.called)
     self.interest.notify_stewards.assert_called_with("Walter", email, "en", "It really tied the room together.")
예제 #5
0
 def test_existing_user_interested(self):
     """Successful submission of the form for existing newsletter user."""
     email = "*****@*****.**"
     sub = models.Subscriber.objects.create(email=email)
     token = sub.token
     self.get_user_data.return_value = {
         "status": "ok",
         "format": "T",
         "token": token,
         "newsletters": ["about-mozilla", "mozilla-and-you", "get-involved"],
     }
     tasks.update_get_involved(
         "bowling", "en", "Walter", email, "US", "T", "Y", "It really tied the room together.", None
     )
     self.apply_updates.assert_has_calls(
         [
             call(
                 settings.EXACTTARGET_DATA,
                 {
                     "EMAIL_ADDRESS_": "*****@*****.**",
                     "MODIFIED_DATE_": ANY,
                     "LANGUAGE_ISO2": "en",
                     "COUNTRY_": "US",
                     "TOKEN": token,
                     "GET_INVOLVED_FLG": "Y",
                 },
             ),
             call(settings.EXACTTARGET_INTERESTS, {"TOKEN": token, "INTEREST": "bowling"}),
         ]
     )
     self.send_message.delay.assert_called_with("en_welcome_bowling_T", email, token, "T")
     # not called because 'about-mozilla' already in newsletters
     self.assertFalse(self.send_welcomes.called)
     self.interest.notify_stewards.assert_called_with("Walter", email, "en", "It really tied the room together.")
예제 #6
0
    def test_exact_target_error(self):
        """Successful submission of the form for new user, but ET has a problem."""
        self.get_user_data.side_effect = NewsletterException('Stuffs broke yo.')
        with self.assertRaises(NewsletterException):
            tasks.update_get_involved('bowling', 'en', 'Walter', '*****@*****.**',
                                      'US', 'T', 'Y', 'It really tied the room together.', None)

        self.assertFalse(self.send_message.called)
        self.assertFalse(self.send_welcomes.called)
        self.assertFalse(self.interest.notify_stewards.called)
예제 #7
0
    def test_exact_target_error(self):
        """Successful submission of the form for new user, but ET has a problem."""
        self.get_user_data.side_effect = NewsletterException("Stuffs broke yo.")
        with self.assertRaises(NewsletterException):
            tasks.update_get_involved(
                "bowling",
                "en",
                "Walter",
                "*****@*****.**",
                "US",
                "T",
                "Y",
                "It really tied the room together.",
                None,
            )

        self.assertFalse(self.send_message.called)
        self.assertFalse(self.send_welcomes.called)
        self.assertFalse(self.interest.notify_stewards.called)