Ejemplo n.º 1
0
    def test_record(self):
        d = DistributionSummary(self.tid,
                                meter_type="D",
                                writer=MemoryWriter())
        self.assertTrue(d._writer.is_empty())

        d.record(42)
        self.assertEqual("D:test:42", d._writer.last_line())
Ejemplo n.º 2
0
    def test_count_and_total_time(self):
        """Avoid breaking the API."""
        t = Timer(self.tid, writer=MemoryWriter())
        self.assertTrue(t._writer.is_empty())

        t.record(42)
        self.assertEqual(0, t.count())
        self.assertEqual(0, t.total_time())
Ejemplo n.º 3
0
    def test_count_and_total_amount(self):
        """Avoid breaking the API."""
        d = DistributionSummary(self.tid, writer=MemoryWriter())
        self.assertTrue(d._writer.is_empty())

        d.record(42)
        self.assertEqual(0, d.count())
        self.assertEqual(0, d.total_amount())
Ejemplo n.º 4
0
 def test_record_zero(self):
     d = DistributionSummary(self.tid,
                             meter_type="D",
                             writer=MemoryWriter())
     d.record(0)
     self.assertEqual("D:test:0", d._writer.last_line())
Ejemplo n.º 5
0
 def test_record_negative(self):
     d = DistributionSummary(self.tid,
                             meter_type="D",
                             writer=MemoryWriter())
     d.record(-42)
     self.assertTrue(d._writer.is_empty())
Ejemplo n.º 6
0
    def test_set_negative(self):
        c = MonotonicCounter(self.tid, writer=MemoryWriter())
        self.assertTrue(c._writer.is_empty())

        c.set(-1)
        self.assertEqual("C:test:-1", c._writer.last_line())
Ejemplo n.º 7
0
 def test_count(self):
     """Avoid breaking the API."""
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment()
     self.assertEqual(0, c.count())
Ejemplo n.º 8
0
 def test_increment_negative(self):
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment(-1)
     self.assertTrue(c._writer.is_empty())
Ejemplo n.º 9
0
    def test_increment(self):
        c = Counter(self.tid, writer=MemoryWriter())
        self.assertTrue(c._writer.is_empty())

        c.increment()
        self.assertEqual("c:test:1", c._writer.last_line())
Ejemplo n.º 10
0
 def test_stopwatch(self):
     clock = ManualClock()
     t = Timer(self.tid, clock=clock, meter_type="T", writer=MemoryWriter())
     with t.stopwatch():
         clock.set_monotonic_time(42)
     self.assertEqual("T:test:42", t._writer.last_line())
Ejemplo n.º 11
0
 def test_record_zero(self):
     t = Timer(self.tid, meter_type="T", writer=MemoryWriter())
     t.record(0)
     self.assertEqual("T:test:0", t._writer.last_line())
Ejemplo n.º 12
0
 def test_record_negative(self):
     t = Timer(self.tid, meter_type="T", writer=MemoryWriter())
     t.record(-42)
     self.assertTrue(t._writer.is_empty())
Ejemplo n.º 13
0
    def test_record(self):
        t = Timer(self.tid, meter_type="T", writer=MemoryWriter())
        self.assertTrue(t._writer.is_empty())

        t.record(42)
        self.assertEqual("T:test:42", t._writer.last_line())
Ejemplo n.º 14
0
    def test_set(self):
        g = MaxGauge(self.tid, writer=MemoryWriter())
        self.assertTrue(g._writer.is_empty())

        g.set(0)
        self.assertEqual("m:test:0", g._writer.last_line())
Ejemplo n.º 15
0
 def test_get(self):
     """Avoid breaking the API."""
     g = Gauge(self.tid, writer=MemoryWriter())
     g.set(1)
     self.assertEqual(0, g.get())
Ejemplo n.º 16
0
 def test_custom_ttl(self):
     g = Gauge(self.tid, ttl_seconds=120, writer=MemoryWriter())
     g.set(42)
     self.assertEqual("g,120:test:42", g._writer.last_line())