Beispiel #1
0
 def __init__(self, sum=None):
     super(SumAggregation, self).__init__()
     self._aggregation_type = "sum"
     if sum is not None:
         self._sum = aggregation_data.SumAggregationDataFloat(sum_data=sum)
     else:
         self._sum = aggregation_data.SumAggregationDataFloat(sum_data=0)
    def test_add_sample(self):
        sum_data = 1
        value = 3
        sum_aggregation_data = aggregation_data_module.SumAggregationDataFloat(
            sum_data=sum_data)
        sum_aggregation_data.add_sample(value, None, None)

        self.assertEqual(4, sum_aggregation_data.sum_data)
 def test_to_point(self):
     sum_data = 12.345
     timestamp = datetime(1970, 1, 1)
     agg = aggregation_data_module.SumAggregationDataFloat(sum_data)
     converted_point = agg.to_point(timestamp)
     self.assertTrue(isinstance(converted_point, point.Point))
     self.assertTrue(isinstance(converted_point.value, value.ValueDouble))
     self.assertEqual(converted_point.value.value, sum_data)
     self.assertEqual(converted_point.timestamp, timestamp)
    def test_constructor(self):
        sum_data = 1
        sum_aggregation_data = aggregation_data_module.SumAggregationDataFloat(
            sum_data=sum_data)

        self.assertEqual(1, sum_aggregation_data.sum_data)
 def __init__(self, sum=None, aggregation_type=Type.SUM):
     super(SumAggregation, self).__init__(aggregation_type=aggregation_type)
     self._sum = aggregation_data.SumAggregationDataFloat(
         sum_data=float(sum or 0))
     self.aggregation_data = self._sum