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'
                                             }})
Example #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'
                }
            })
    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)
    def test_group_by_time(self):
        self.metric.group_by(time=(1, 'milliseconds', 2))

        self.assertEqual(self.metric.group_bys,
                         [TimeGroupBy(1, 'milliseconds', 2)])
Example #5
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)
Example #6
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')
Example #7
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)
Example #8
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)
Example #9
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)
Example #10
0
 def test_should_fail_if_invalid_length_of_arguments(self):
     with self.assertRaisesRegexp(GroupByException,
                                  "Invalid args length: 2, must be a 3 .*"):
         TimeGroupBy.from_arguments(('invalid', 'length'))
Example #11
0
 def test_should_fail_if_arguments_are_not_list(self):
     with self.assertRaisesRegexp(
             GroupByException,
             "Invalid args type: <type 'str'>, must be a list or tuple."):
         TimeGroupBy.from_arguments('not_a_list')
Example #12
0
    def test_from_arguments(self):
        group_by = TimeGroupBy.from_arguments((2, 'days', 500))

        self.assertEqual(group_by.range_value, 2)
        self.assertEqual(group_by.range_unit, 'days')
        self.assertEqual(group_by.group_count, 500)
 def test_should_fail_if_invalid_length_of_arguments(self):
     with self.assertRaisesRegexp(GroupByException, "Invalid args length: 2, must be a 3 .*"):
         TimeGroupBy.from_arguments(('invalid', 'length'))
 def test_should_fail_if_arguments_are_not_list(self):
     with self.assertRaisesRegexp(GroupByException, "Invalid args type: <type 'str'>, must be a list or tuple."):
         TimeGroupBy.from_arguments('not_a_list')
    def test_from_arguments(self):
        group_by = TimeGroupBy.from_arguments((2, 'days', 500))

        self.assertEqual(group_by.range_value, 2)
        self.assertEqual(group_by.range_unit, 'days')
        self.assertEqual(group_by.group_count, 500)