Exemplo n.º 1
0
    def test_group_by_as_args(self):
        groupers = [
            TagGroupBy(['host']),
            TimeGroupBy(1, 'milliseconds', 2),
            ValueGroupBy(1)
        ]
        self.metric.group_by(*groupers)

        self.assertEqual(self.metric.group_bys, groupers)
Exemplo n.º 2
0
    def test_format(self):
        group_by = TimeGroupBy(1, 'days', 500)

        self.assertEqual(
            group_by.format(), {
                'name': 'time',
                'group_count': 500,
                'range_size': {
                    'value': 1,
                    'unit': 'days'
                }
            })
Exemplo n.º 3
0
    def test_group_by_time(self):
        self.metric.group_by(time=(1, 'milliseconds', 2))

        self.assertEqual(self.metric.group_bys,
                         [TimeGroupBy(1, 'milliseconds', 2)])
Exemplo n.º 4
0
 def test_should_fail_if_group_count_is_below_zero(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid group_count value: -1, must be greater than 0."):
         TimeGroupBy(1, 'days', -1)
Exemplo n.º 5
0
 def test_should_fail_if_group_count_not_int(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid group_count type: <type 'str'>, must be int."):
         TimeGroupBy(1, 'days', 'not_int')
Exemplo n.º 6
0
 def test_should_fail_if_invalid_range_unit(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid range_unit value: invalid_unit, must be .*"):
         TimeGroupBy(1, 'invalid_unit', 500)
Exemplo n.º 7
0
 def test_should_fail_if_range_value_not_int(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid range_value type: <type 'str'>, must be int."):
         TimeGroupBy('not_int', 'days', 500)
Exemplo n.º 8
0
 def test_should_fail_if_range_value_is_below_zero(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid range_value value: -1, must be greater than 0."):
         TimeGroupBy(-1, 'days', 500)