def test_clear(self): stat_obj = Stat('test_stat', self.resq) stat_obj.incr() stat_obj.incr() assert self.redis.exists('resque:stat:test_stat') stat_obj.clear() assert not self.redis.exists('resque:stat:test_stat')
def test_incr(self): stat_obj = Stat('test_stat', self.resq) stat_obj.incr() assert self.redis.get('resque:stat:test_stat') == str(1) stat_obj.incr() assert self.redis.get('resque:stat:test_stat') == str(2) stat_obj.incr(2) assert self.redis.get('resque:stat:test_stat') == str(4)
def test_incr(self): stat_obj = Stat('test_stat', self.resq) stat_obj.incr() assert self.redis.get('resque:stat:test_stat') == b'1' stat_obj.incr() assert self.redis.get('resque:stat:test_stat') == b'2' stat_obj.incr(2) assert self.redis.get('resque:stat:test_stat') == b'4'
def unregister_worker(self): self.resq.redis.srem('resque:workers', str(self)) self.started = None Stat("processed:%s" % self, self.resq).clear() Stat("failed:%s" % self, self.resq).clear()
def get_failed(self): return Stat("failed:%s" % self, self.resq).get()
def failed(self): Stat("failed", self.resq).incr() Stat("failed:%s" % self, self.resq).incr()
def get_processed(self): return Stat("processed:%s" % str(self), self.resq).get()
def processed(self): total_processed = Stat("processed", self.resq) worker_processed = Stat("processed:%s" % str(self), self.resq) total_processed.incr() worker_processed.incr()
def test_get(self): stat_obj = Stat('test_stat', self.resq) stat_obj.incr() stat_obj.incr() assert stat_obj.get() == 2
def processed(self): total_processed = Stat("processed", self.resq) total_processed.incr()
def failed(self): Stat("failed", self.resq).incr()