Ejemplo n.º 1
0
 def test_unsubscribe_from_basket_task(self, unsubscribe_mock, switch_is_active_mock):
     switch_is_active_mock.return_value = True
     user = UserFactory.create(userprofile={'basket_token': 'foo'})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email, user.userprofile.basket_token, ['foo'])
     unsubscribe_mock.assert_called_with(
         user.userprofile.basket_token, user.email, newsletters=['foo'])
Ejemplo n.º 2
0
 def test_unsubscribe_from_basket_task(self, unsubscribe_mock):
     user = UserFactory.create(userprofile={'basket_token': 'foo'})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email,
                                      user.userprofile.basket_token)
     unsubscribe_mock.assert_called_with(user.userprofile.basket_token,
                                         user.email,
                                         newsletters='newsletter')
Ejemplo n.º 3
0
 def test_unsubscribe_from_basket_task_without_token(self, lookup_token_mock, basket_mock):
     lookup_token_mock.return_value = 'basket_token'
     basket_mock.lookup_user.return_value = {'token': 'basket_token'}
     user = UserFactory.create(userprofile={'basket_token': ''})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email, user.userprofile.basket_token)
     user = User.objects.get(pk=user.pk)  # refresh data from DB
     basket_mock.unsubscribe.assert_called_with(
         'basket_token', user.email, newsletters='newsletter')
Ejemplo n.º 4
0
 def test_unsubscribe_from_basket_task(self, unsubscribe_mock,
                                       switch_is_active_mock):
     switch_is_active_mock.return_value = True
     user = UserFactory.create(userprofile={'basket_token': 'foo'})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email,
                                      user.userprofile.basket_token,
                                      ['foo'])
     unsubscribe_mock.assert_called_with(user.userprofile.basket_token,
                                         user.email,
                                         newsletters=['foo'])
Ejemplo n.º 5
0
 def test_unsubscribe_from_basket_task_without_token(
         self, lookup_token_mock, basket_mock):
     lookup_token_mock.return_value = 'basket_token'
     basket_mock.lookup_user.return_value = {'token': 'basket_token'}
     user = UserFactory.create(userprofile={'basket_token': ''})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email,
                                      user.userprofile.basket_token)
     user = User.objects.get(pk=user.pk)  # refresh data from DB
     basket_mock.unsubscribe.assert_called_with('basket_token',
                                                user.email,
                                                newsletters='newsletter')
Ejemplo n.º 6
0
    def test_unsubscribe_from_basket_task(self, basket_mock, lookup_mock, unsubscribe_mock,
                                          switch_is_active_mock):
        switch_is_active_mock.return_value = True
        user = UserFactory.create(email='*****@*****.**')
        basket_mock.lookup_user.return_value = {
            'email': user.email,  # the old value
            'token': 'token',
            'newsletters': ['foo', 'bar']
        }

        lookup_mock.reset_mock()
        unsubscribe_mock.reset_mock()

        with patch('mozillians.users.tasks.BASKET_ENABLED', True):
            unsubscribe_from_basket_task(user.email, ['foo'])
        eq_(lookup_mock.subtask.call_count, 1)
        eq_(unsubscribe_mock.subtask.call_count, 1)
        lookup_mock.subtask.assert_called_with((user.email,))
        unsubscribe_mock.subtask.called_with((['foo'],))
Ejemplo n.º 7
0
    def test_unsubscribe_from_basket_task(self, basket_mock, lookup_mock, unsubscribe_mock,
                                          switch_is_active_mock):
        switch_is_active_mock.return_value = True
        user = UserFactory.create(email='*****@*****.**').userprofile
        basket_mock.lookup_user.return_value = {
            'email': user.email,  # the old value
            'token': 'token',
            'newsletters': ['foo', 'bar']
        }

        lookup_mock.reset_mock()
        unsubscribe_mock.reset_mock()

        with patch('mozillians.users.tasks.BASKET_ENABLED', True):
            unsubscribe_from_basket_task(user.email, ['foo'])
        eq_(lookup_mock.subtask.call_count, 1)
        eq_(unsubscribe_mock.subtask.call_count, 1)
        lookup_mock.subtask.assert_called_with((user.email,))
        unsubscribe_mock.subtask.called_with((['foo'],))
Ejemplo n.º 8
0
 def test_unsubscribe_from_basket_task(self, unsubscribe_mock):
     user = UserFactory.create(userprofile={'basket_token': 'foo'})
     with patch('mozillians.users.tasks.BASKET_ENABLED', True):
         unsubscribe_from_basket_task(user.email, user.userprofile.basket_token)
     unsubscribe_mock.assert_called_with(
         user.userprofile.basket_token, user.email, newsletters='newsletter')