예제 #1
0
    def test_stat_user_channel(self, *args):
        user_channel_vos = UserChannelFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_channel_vos))

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

        self.transaction.method = 'stat'
        user_channel_svc = UserChannelService(transaction=self.transaction)
        values = user_channel_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_user_channel')
예제 #2
0
    def test_list_user_channels_by_name(self, *args):
        user_channel_vos = UserChannelFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_channel_vos))

        params = {
            'name': user_channel_vos[0].name,
            'domain_id': self.domain_id
        }

        self.transaction.method = 'list'
        user_channel_svc = UserChannelService(transaction=self.transaction)
        user_channel_vos, total_count = user_channel_svc.list(params)
        UserChannelsInfo(user_channel_vos, total_count)

        self.assertEqual(len(user_channel_vos), 1)
        self.assertIsInstance(user_channel_vos[0], UserChannel)
        self.assertEqual(total_count, 1)
예제 #3
0
    def test_stat_user_channel_distinct(self, *args):
        user_channel_vos = UserChannelFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_channel_vos))

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

        self.transaction.method = 'stat'
        user_channel_svc = UserChannelService(transaction=self.transaction)
        values = user_channel_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_user_channel_distinct')