コード例 #1
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'
                                             }})
コード例 #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'
                }
            })
コード例 #3
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)
コード例 #4
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)])
コード例 #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)
コード例 #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')
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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'))
コード例 #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')
コード例 #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)
コード例 #13
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'))
コード例 #14
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')
コード例 #15
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)