def test_bitmap_counter(self):
        counter = BitMapCounter(key='test_key')
        counter.setup(redis_conn=self.redis_conn)

        counter.increment(0)
        counter.increment(1)
        counter.increment(5)
        counter.increment(0)
        self.assertEqual(3, counter.value())
        counter.stop()
        self.clean_keys(counter.key)
    def test_roll_bitmap_counter(self):
        # rough sleep to get us back on track
        time.sleep(2 - (int(time.time()) % 2))
        counter = BitMapCounter(key='test_key', window=2, cycle_time=.1,
                                roll=True)
        counter.setup(redis_conn=self.redis_conn)

        counter.increment(0)
        counter.increment(1)
        counter.increment(0)
        self.assertEqual(2, counter.value())
        time.sleep(3)
        counter.increment(0)
        self.assertEqual(1, counter.value())
        counter.stop()
        self.clean_keys(counter.key)
Exemple #3
0
    def test_roll_bitmap_counter(self):
        # rough sleep to get us back on track
        time.sleep(2 - (int(time.time()) % 2))
        counter = BitMapCounter(key='test_key',
                                window=2,
                                cycle_time=.1,
                                roll=True)
        counter.setup(redis_conn=self.redis_conn)

        counter.increment(0)
        counter.increment(1)
        counter.increment(0)
        self.assertEqual(2, counter.value())
        time.sleep(3)
        counter.increment(0)
        self.assertEqual(1, counter.value())
        counter.stop()
        self.clean_keys(counter.key)
Exemple #4
0
    def test_bitmap_counter(self):
        counter = BitMapCounter(key='test_key')
        counter.setup(redis_conn=self.redis_conn)

        counter.increment(0)
        counter.increment(1)
        counter.increment(5)
        counter.increment(0)
        self.assertEqual(3, counter.value())
        counter.stop()
        self.clean_keys(counter.key)