示例#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())
示例#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())
示例#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())
示例#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())
示例#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())
示例#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())
示例#7
0
 def test_count(self):
     """Avoid breaking the API."""
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment()
     self.assertEqual(0, c.count())
示例#8
0
 def test_increment_negative(self):
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment(-1)
     self.assertTrue(c._writer.is_empty())
示例#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())
示例#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())
示例#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())
示例#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())
示例#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())
示例#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())
示例#15
0
 def test_get(self):
     """Avoid breaking the API."""
     g = Gauge(self.tid, writer=MemoryWriter())
     g.set(1)
     self.assertEqual(0, g.get())
示例#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())