def test_column_group_measurement(self):
     measurement = Measurement(
         metric=Metric.MIN,
         column_name='AGE',
         group_values=[GroupValue(group={'country': 'US'}, value=3.4)])
     self.assertEqual("min(AGE): \n  group{'country': 'US'} = 3.4",
                      str(measurement))
     JsonHelper.to_json(JsonHelper.to_jsonnable(measurement.to_dict()))
Esempio n. 2
0
 def __str__(self):
     column_str = f'({self.column_name})' if self.column_name else ''
     group_values_str = JsonHelper.to_json(
         JsonHelper.to_jsonnable(
             self.group_values)) if self.group_values else ''
     value_str = '' if self.value is None \
                 else (' = ' + (', '.join([str(e) for e in self.value]) if isinstance(self.value, list)
                               else str(self.value)))
     return f'{self.metric}{column_str}{group_values_str}{value_str}'
 def test_column_group_measurement_empty_list(self):
     measurement = Measurement(metric=Metric.MIN,
                               column_name='AGE',
                               group_values=[])
     self.assertEqual('min(AGE): no groups', str(measurement))
     JsonHelper.to_json(JsonHelper.to_jsonnable(measurement.to_dict()))
 def test_column_measurement_list_value(self):
     measurement = Measurement(metric=Metric.MINS,
                               column_name='chars',
                               value=['a', 'b'])
     self.assertEqual("mins(chars) = ['a', 'b']", str(measurement))
     JsonHelper.to_json(JsonHelper.to_jsonnable(measurement.to_dict()))
 def test_column_measurement(self):
     measurement = Measurement(metric=Metric.MIN,
                               column_name='AGE',
                               value=3.4)
     self.assertEqual('min(AGE) = 3.4', str(measurement))
     JsonHelper.to_json(JsonHelper.to_jsonnable(measurement.to_dict()))
 def test_row_count(self):
     measurement = Measurement(metric=Metric.ROW_COUNT, value=5)
     self.assertEqual('row_count = 5', str(measurement))
     JsonHelper.to_json(JsonHelper.to_jsonnable(measurement.to_dict()))