def test_record_multiple(self):
     t = DistributionSummary(DistributionSummaryTest.tid)
     t.record(42)
     t.record(2)
     t.record(7)
     self.assertEqual(t.count(), 3)
     self.assertEqual(t.total_amount(), 51)
Exemple #2
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())
    def test_measure(self):
        t = DistributionSummary(DistributionSummaryTest.tid)
        t.record(42)
        t.record(2)
        t.record(7)
        ms = t._measure()

        def get_stat(s):
            return ms[DistributionSummaryTest.tid.with_stat(s)]

        self.assertEqual(len(ms), 4)
        self.assertEqual(get_stat('count'), 3)
        self.assertEqual(get_stat('totalAmount'), 51)
        self.assertEqual(get_stat('max'), 42)
        self.assertEqual(get_stat('totalOfSquares'), 42**2 + 2**2 + 7**2)

        self.assertEqual(t.count(), 0)
        self.assertEqual(t.total_amount(), 0)
 def test_record(self):
     t = DistributionSummary(DistributionSummaryTest.tid)
     t.record(42)
     self.assertEqual(t.count(), 1)
     self.assertEqual(t.total_amount(), 42)
 def test_record_negative(self):
     t = DistributionSummary(DistributionSummaryTest.tid)
     t.record(-42)
     self.assertEqual(t.count(), 0)
     self.assertEqual(t.total_amount(), 0)