コード例 #1
0
ファイル: test_tasks.py プロジェクト: Shvn/mozillians
 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'])
コード例 #2
0
ファイル: test_tasks.py プロジェクト: ppapadeas/mozillians
 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')
コード例 #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')
コード例 #4
0
ファイル: test_tasks.py プロジェクト: raj-maurya/mozillians
 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'])
コード例 #5
0
ファイル: test_tasks.py プロジェクト: ppapadeas/mozillians
 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')
コード例 #6
0
ファイル: test_tasks.py プロジェクト: viorelaioia/mozillians
    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'],))
コード例 #7
0
ファイル: test_tasks.py プロジェクト: akatsoulas/mozillians
    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'],))
コード例 #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')