def _validate_single_metric(self, metric):
     validation.metric_name(metric['name'])
     assert isinstance(metric['timestamp'], (int, float)), "Timestamp must be a number"
     assert isinstance(metric['value'], (int, long, float)), "Value must be a number"
     if "dimensions" in metric:
         for dimension_key in metric['dimensions']:
             validation.dimension_key(dimension_key)
             validation.dimension_value(metric['dimensions'][dimension_key])
Beispiel #2
0
 def _validate_single_metric(self, metric):
     validation.metric_name(metric['name'])
     assert isinstance(metric['timestamp'],
                       (int, float)), "Timestamp must be a number"
     assert isinstance(metric['value'],
                       (int, long, float)), "Value must be a number"
     if "dimensions" in metric:
         for dimension_key in metric['dimensions']:
             validation.dimension_key(dimension_key)
             validation.dimension_value(metric['dimensions'][dimension_key])
Beispiel #3
0
 def _validate_dimensions(dimensions):
     try:
         assert isinstance(dimensions, list)
         for dimension in dimensions:
             name_value = dimension.split('=')
             validation.dimension_key(name_value[0])
             if len(name_value) > 1 and '|' in name_value[1]:
                 values = name_value[1].split('|')
                 for value in values:
                     validation.dimension_value(value)
     except Exception as e:
         raise HTTPUnprocessableEntityError("Unprocessable Entity", e.message)
Beispiel #4
0
 def _validate_dimensions(dimensions):
     try:
         assert isinstance(dimensions, list)
         for dimension in dimensions:
             name_value = dimension.split(':')
             validation.dimension_key(name_value[0])
             if len(name_value) > 1:
                 if '|' in name_value[1]:
                     values = name_value[1].split('|')
                     for value in values:
                         validation.dimension_value(value)
                 else:
                     validation.dimension_value(name_value[1])
     except Exception as e:
         raise HTTPUnprocessableEntityError("Unprocessable Entity", e.message)
 def test_valid_value(self):
     dim_value = "this.is_a.valid-value"
     validation.dimension_value(dim_value)
     self.assertTrue(True)
Beispiel #6
0
 def test_valid_value(self):
     dim_value = "this.is_a.valid-value"
     validation.dimension_value(dim_value)
     self.assertTrue(True)