def test_constructor_with_none_count_sum(self): snapshot = summary_module.Snapshot(None, None, self.value_at_percentile) self.assertIsNotNone(snapshot) self.assertIsNone(snapshot.count) self.assertIsNone(snapshot.sum_data) self.assertIsNotNone(snapshot.value_at_percentiles) self.assertEqual(len(snapshot.value_at_percentiles), 1)
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 test_constructor(self): snapshot = summary_module.Snapshot(10, 87.07, self.value_at_percentile) self.assertIsNotNone(snapshot) self.assertEqual(snapshot.count, 10) self.assertEqual(snapshot.sum_data, 87.07) self.assertIsNotNone(snapshot.value_at_percentiles) self.assertEqual(len(snapshot.value_at_percentiles), 1) self.assertEqual(snapshot.value_at_percentiles[0].percentile, 99.5) self.assertEqual(snapshot.value_at_percentiles[0].value, 10.2)
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_zero_count_and_sum_data(self): summary_module.Snapshot(0, 0, self.value_at_percentile)
def test_constructor_with_zero_count(self): with assertRaisesRegex(self, ValueError, 'sum_data must be 0 if count is 0'): summary_module.Snapshot(0, 87.07, self.value_at_percentile)
def test_constructor_with_negative_sum_data(self): with assertRaisesRegex(self, ValueError, 'sum_data must be non-negative'): summary_module.Snapshot(10, -87.07, self.value_at_percentile)
def test_constructor_empty_value_at_percentile(self): snapshot = summary_module.Snapshot(10, 87.07) self.assertIsNotNone(snapshot) self.assertIsNotNone(snapshot.value_at_percentiles) self.assertEqual(len(snapshot.value_at_percentiles), 0)
def test_constructor_invalid_value_at_percentile(self): with self.assertRaises(ValueError): summary_module.Snapshot(10, 87.07, self.value_at_percentile1)
def setUp(self): value_at_percentile = [summary_module.ValueAtPercentile(99.5, 10.2)] self.snapshot = summary_module.Snapshot(10, 87.07, value_at_percentile)