def print_counters(counters, current_epoch_sec): print "%64s || %10s || %10s || %10s" % ( "name", "last min", "last hr", "all time") print "-" * 150 for counter_wrapper in counters: counter_stats = stats.CounterStats(counter_wrapper["value"], current_epoch_sec) print "%64s || %10d || %10d || %10d" % \ (counter_wrapper["name"], counter_stats.last_minute_count(), counter_stats.last_hour_count(), counter_stats.all_time_count())
def test_all_time_count(self): s = stats.CounterStats(self.createFakeData(), 610*60) self.assertEquals(5000, s.all_time_count())
def test_last_hour_count_returns_zero_for_more_than_1_hr_ahead(self): s = stats.CounterStats(self.createFakeData(), 675*60) self.assertEquals(0, s.last_hour_count())
def test_last_hour_count_returns_zero_for_future_time(self): s = stats.CounterStats(self.createFakeData(), 610*60) self.assertEquals(0, s.last_hour_count())
def test_last_hour_count_for_partial_hour(self): s = stats.CounterStats(self.createFakeData(), 620*60) self.assertEquals(1770-16-17-18-19-20, s.last_hour_count())
def test_last_hour_count_for_full_hour(self): s = stats.CounterStats(self.createFakeData(), 615*60) self.assertEquals(1770, s.last_hour_count())
def test_last_minute_count_for_prior_minute_returns_zero(self): s = stats.CounterStats(self.createFakeData(), 616*60) self.assertEquals(0, s.last_minute_count())
def test_last_minute_count_diff_second_in_same_minute(self): s = stats.CounterStats(self.createFakeData(), 615*60+15) self.assertEquals(15, s.last_minute_count())
def test_last_minute_count(self): s = stats.CounterStats(self.createFakeData(), 615*60) self.assertEquals(15, s.last_minute_count())