Пример #1
0
    def test_tags_cache_forever(self):
        store = DictStore()

        tags = ['bop', 'zap']
        store.tags(*tags).forever('foo', 'bar')

        self.assertEqual('bar', store.tags(tags).get('foo'))
Пример #2
0
    def test_cache_can_be_set_with_datetime(self):
        store = DictStore()
        duration = datetime.now() + timedelta(minutes=10)

        store.tags('bop').put('foo', 'bar', duration)

        self.assertEqual('bar', store.tags('bop').get('foo'))
Пример #3
0
    def test_tags_can_be_flushed(self):
        store = DictStore()

        store.tags('bop').put('foo', 'bar', 10)
        store.tags('zap').put('baz', 'boom', 10)
        store.tags('bop').flush()

        self.assertIsNone(store.tags('bop').get('foo'))
        self.assertEqual('boom', store.tags('zap').get('baz'))
Пример #4
0
    def test_cache_saved_with_multiple_tags_can_be_flushed(self):
        store = DictStore()

        tags = ['bop', 'zap']
        store.tags(*tags).put('foo', 'bar', 10)
        tags2 = ['bam', 'pow']
        store.tags(*tags2).put('foo', 'bar', 10)
        store.tags('zap').flush()

        self.assertIsNone(store.tags(tags).get('foo'))
        self.assertEqual('bar', store.tags(tags2).get('foo'))
Пример #5
0
    def test_items_can_be_flushed(self):
        store = DictStore()
        store.put('foo', 'bar', 10)
        store.put('baz', 'boom', 10)
        store.flush()

        self.assertIsNone(store.get('foo'))
        self.assertIsNone(store.get('baz'))
Пример #6
0
    def test_items_can_be_flushed(self):
        store = DictStore()
        store.put('foo', 'bar', 10)
        store.put('baz', 'boom', 10)
        store.flush()

        self.assertIsNone(store.get('foo'))
        self.assertIsNone(store.get('baz'))
Пример #7
0
    def test_cache_can_be_saved_with_multiple_tags(self):
        store = DictStore()

        tags = ['bop', 'zap']
        store.tags(*tags).put('foo', 'bar', 10)
        self.assertEqual('bar', store.tags(tags).get('foo'))
Пример #8
0
    def test_cache_key(self):
        store = DictStore()

        self.assertEqual('', store.get_prefix())
Пример #9
0
    def test_values_can_be_removed(self):
        store = DictStore()
        store.put('foo', 'bar', 10)
        store.forget('foo')

        self.assertIsNone(store.get('foo'))
Пример #10
0
    def test_values_can_be_decremented(self):
        store = DictStore()
        store.put('foo', 1, 10)
        store.decrement('foo')

        self.assertEqual(0, store.get('foo'))
Пример #11
0
    def test_items_can_be_set_and_retrieved(self):
        store = DictStore()
        store.put('foo', 'bar', 10)

        self.assertEqual('bar', store.get('foo'))
Пример #12
0
    def test_cache_key(self):
        store = DictStore()

        self.assertEqual('', store.get_prefix())
Пример #13
0
    def test_values_can_be_removed(self):
        store = DictStore()
        store.put('foo', 'bar', 10)
        store.forget('foo')

        self.assertIsNone(store.get('foo'))
Пример #14
0
    def test_values_can_be_decremented(self):
        store = DictStore()
        store.put('foo', 1, 10)
        store.decrement('foo')

        self.assertEqual(0, store.get('foo'))
Пример #15
0
 def test_store_item_forever_properly_stores_in_dict(self):
     mock = flexmock(DictStore())
     mock.should_receive('put').once().with_args('foo', 'bar', 0)
     mock.forever('foo', 'bar')
Пример #16
0
    def test_items_can_be_set_and_retrieved(self):
        store = DictStore()
        store.put('foo', 'bar', 10)

        self.assertEqual('bar', store.get('foo'))