def test_constructor(self): summary = summary_module.Summary(10, 6.6, self.snapshot) self.assertIsNotNone(summary) self.assertEqual(summary.count, 10) self.assertEqual(summary.sum_data, 6.6) self.assertIsNotNone(summary.snapshot) self.assertIsInstance(summary.snapshot, summary_module.Snapshot)
def test_create_summary_value(self): value_at_percentile = [summary_module.ValueAtPercentile(99.5, 10.2)] snapshot = summary_module.Snapshot(10, 87.07, value_at_percentile) summary = summary_module.Summary(10, 6.6, snapshot) summary_value = value_module.Value.summary_value(summary) self.assertIsNotNone(summary_value) self.assertIsInstance(summary_value, value_module.ValueSummary) self.assertEqual(summary_value.value, summary)
def setUp(self): self.double_value = value_module.Value.double_value(55.5) self.long_value = value_module.Value.long_value(9876543210) self.timestamp = '2018-10-06T17:57:57.936475Z' value_at_percentile = [summary_module.ValueAtPercentile(99.5, 10.2)] snapshot = summary_module.Snapshot(10, 87.07, value_at_percentile) self.summary = summary_module.Summary(10, 6.6, snapshot) self.summary_value = value_module.Value.summary_value(self.summary) self.distribution_value = value_module.ValueDistribution( 100, 1000.0, 10.0, list(range(11)), [value_module.Bucket(10, None) for ii in range(10)], )
def test_constructor_with_none_snapshot(self): with assertRaisesRegex(self, ValueError, 'snapshot must not be none'): summary_module.Summary(10, 87.07, None)
def test_constructor_with_zero_count_and_sum_data(self): with assertRaisesRegex(self, ValueError, 'sum_data must be 0 if count is 0'): summary_module.Summary(0, 87.07, self.snapshot)
def test_constructor_with_negative_sum_data(self): with assertRaisesRegex(self, ValueError, 'sum_data must be non-negative'): summary_module.Summary(10, -87.07, self.snapshot)
def test_constructor_with_negative_count(self): with assertRaisesRegex(self, ValueError, 'count must be non-negative'): summary_module.Summary(-10, 87.07, self.snapshot)