Exemple #1
0
 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)
Exemple #2
0
 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')])
Exemple #3
0
 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')])
Exemple #4
0
 def test_set(self):
     g = Gauge(GaugeTest.tid)
     self.assertTrue(math.isnan(g.get()))
     g.set(1)
     self.assertEqual(g.get(), 1)
Exemple #5
0
 def test_get(self):
     """Avoid breaking the API."""
     g = Gauge(self.tid, writer=MemoryWriter())
     g.set(1)
     self.assertEqual(0, g.get())