def test_measure(self):
     c = Counter(CounterTest.tid)
     c.increment()
     ms = c._measure()
     self.assertEqual(len(ms), 1)
     self.assertEqual(ms[CounterTest.tid.with_stat('count')], 1)
     self.assertEquals(c.count(), 0)
Esempio n. 2
0
 def counter(self, name, tags=None):
     return self._new_meter(name, tags, lambda id: Counter(id), Counter,
                            self.noopCounter)
Esempio n. 3
0
 def test_count(self):
     """Avoid breaking the API."""
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment()
     self.assertEqual(0, c.count())
Esempio n. 4
0
 def test_increment_negative(self):
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment(-1)
     self.assertTrue(c._writer.is_empty())
Esempio n. 5
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())
 def test_increment(self):
     c = Counter(CounterTest.tid)
     self.assertEqual(c.count(), 0)
     c.increment()
     self.assertEqual(c.count(), 1)
 def test_increment_negative(self):
     c = Counter(CounterTest.tid)
     c.increment(-1)
     self.assertEqual(c.count(), 0)
Esempio n. 8
0
 def test_user_statistic(self):
     c = Counter(CounterTest.tid.with_stat('totalTime'))
     c.increment()
     for id in c._measure().keys():
         self.assertEqual('totalTime', id.tags()['statistic'])
Esempio n. 9
0
 def counter(self, name: str, tags: Optional[dict] = None) -> Counter:
     return Counter(self._new_meter(name, tags), writer=self._writer)