def test_delta(self): counter = MockCounter(total=100, min_delta=0, manager=self.manager) counter.update() self.assertEqual(counter.output, [1]) counter.update() self.assertEqual(counter.output, [1, 2]) counter.min_delta = 500 counter.update() self.assertEqual(counter.output, [1, 2]) counter.min_delta = .01 time.sleep(.01) counter.update() self.assertEqual(counter.output, [1, 2, 4])
def test_refresh_total(self): counter = MockCounter(total=100, min_delta=0, manager=self.manager) counter.update() self.assertEqual(counter.output, [1]) counter.min_delta = 500 counter.update() self.assertEqual(counter.output, [1]) counter.update(98) self.assertEqual(counter.output, [1, 100])
def test_force(self): counter = MockCounter(total=100, min_delta=0, manager=self.manager) counter.update() self.assertEqual(counter.output, [1]) counter.min_delta = 500 counter.update() self.assertEqual(counter.output, [1]) counter.update(force=True) self.assertEqual(counter.output, [1, 3])
def test_enabled(self): counter = MockCounter(total=100, min_delta=0, manager=self.manager) counter.update() self.assertEqual(counter.output, [1]) counter.update() self.assertEqual(counter.output, [1, 2]) counter.enabled = False counter.update() self.assertEqual(counter.output, [1, 2])
def test_increment(self): counter = MockCounter(total=100, min_delta=0, manager=self.manager) counter.update() self.assertEqual(counter.count, 1) counter.update(5) self.assertEqual(counter.count, 6)