def test_measure(self): g = Gauge(GaugeTest.tid) g.set(42) ms = g._measure() self.assertTrue(math.isnan(g.get())) self.assertEqual(len(ms), 1) self.assertEqual(ms[GaugeTest.tid.with_stat('gauge')], 42)
def test_measure(self): g = Gauge(GaugeTest.tid) g.set(42) ms = g._measure() self.assertEqual(42, g.get()) self.assertEqual(1, len(ms)) self.assertEqual(42, ms[GaugeTest.tid.with_stat('gauge')])
def test_ttl_reset(self): clock = ManualClock() g = Gauge(GaugeTest.tid, clock=clock) g.set(42) clock.set_wall_time(g.ttl + 1) ms = g._measure() self.assertTrue(math.isnan(g.get())) self.assertEqual(1, len(ms)) self.assertEqual(42, ms[GaugeTest.tid.with_stat('gauge')])
def test_set(self): g = Gauge(GaugeTest.tid) self.assertTrue(math.isnan(g.get())) g.set(1) self.assertEqual(g.get(), 1)
def test_get(self): """Avoid breaking the API.""" g = Gauge(self.tid, writer=MemoryWriter()) g.set(1) self.assertEqual(0, g.get())