Esempio n. 1
0
    def test_delete_memoized_essentials(self):
        """Test CACHE delete_memoized_essential deletes all the function
        calls stored if essential parameter is the given value"""
        @memoize_essentials(timeout=300, essentials=[0])
        def my_func(*args, **kwargs):
            return [args, kwargs]

        my_func('arg', kwarg='kwarg')
        my_func('other', kwarg='kwother')
        assert len(test_sentinel.master.keys()) == 2

        delete_succedeed = delete_memoized_essential(my_func, 'other')
        assert delete_succedeed is True, delete_succedeed
        assert len(test_sentinel.master.keys()) == 1
Esempio n. 2
0
    def test_delete_memoized_essentials_no_key(self):
        """Test CACHE delete_memoized_essential no key to delete"""
        @memoize_essentials(timeout=300, essentials=[0])
        def my_func(*args, **kwargs):
            return [args, kwargs]

        @memoize_essentials(timeout=300, essentials=[0])
        def my_other_func(*args, **kwargs):
            return [args, kwargs]

        my_func('arg', kwarg='kwarg')
        my_func('other', kwarg='kwother')
        assert len(test_sentinel.master.keys()) == 2

        delete_succedeed = delete_memoized_essential(my_other_func, 'other')
        assert delete_succedeed is False, delete_succedeed
        assert len(test_sentinel.master.keys()) == 2
Esempio n. 3
0
def delete_browse_tasks(project_id):
    """Reset browse_tasks value in cache"""
    delete_memoized_essential(browse_tasks, project_id)