Beispiel #1
0
    def test_stat_user_configs(self, *args):
        user_config_vos = UserConfigFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_config_vos))

        params = {
            'domain_id': self.domain_id,
            'query': {
                'aggregate': [{
                    'group': {
                        'keys': [{
                            'key': 'name',
                            'name': 'Name'
                        }],
                        'fields': [{
                            'operator': 'count',
                            'name': 'Count'
                        }]
                    }
                }, {
                    'sort': {
                        'key': 'Count',
                        'desc': True
                    }
                }]
            }
        }

        self.transaction.method = 'stat'
        user_config_svc = UserConfigService(transaction=self.transaction)
        values = user_config_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_user_configs')
Beispiel #2
0
    def test_stat_user_configs_distinct(self, *args):
        user_config_vos = UserConfigFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_config_vos))

        params = {
            'domain_id': self.domain_id,
            'query': {
                'distinct': 'name',
                'page': {
                    'start': 2,
                    'limit': 3
                }
            }
        }

        self.transaction.method = 'stat'
        user_config_svc = UserConfigService(transaction=self.transaction)
        values = user_config_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_user_configs_distinct')