Exemple #1
0
    def test_stat_schedule(self, *args):
        schedule_vos = ScheduleFactory.build_batch(10,
                                                   domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schedule_vos))

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

        self.transaction.method = 'stat'
        schedule_svc = ScheduleService(transaction=self.transaction)
        values = schedule_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_schedule')
Exemple #2
0
    def test_list_schedules_by_tag(self, *args):
        ScheduleFactory(tags=[{
            'key': 'tag_key_1',
            'value': 'tag_value_1'
        }],
                        domain_id=self.domain_id)
        schedule_vos = ScheduleFactory.build_batch(9, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schedule_vos))

        params = {
            'query': {
                'filter': [{
                    'k': 'tags.tag_key_1',
                    'v': 'tag_value_1',
                    'o': 'eq'
                }]
            },
            'domain_id': self.domain_id
        }

        self.transaction.method = 'list'
        schedule_svc = ScheduleService(transaction=self.transaction)
        schedule_vos, total_count = schedule_svc.list(params.copy())
        SchedulesInfo(schedule_vos, total_count)

        self.assertEqual(len(schedule_vos), 1)
        self.assertIsInstance(schedule_vos[0], Schedule)
        self.assertEqual(total_count, 1)
Exemple #3
0
    def test_list_schedules_by_topic(self, *args):
        schedule_vos = ScheduleFactory.build_batch(10,
                                                   domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schedule_vos))

        params = {'topic': schedule_vos[0].topic, 'domain_id': self.domain_id}

        self.transaction.method = 'list'
        schedule_svc = ScheduleService(transaction=self.transaction)
        schedule_vos, total_count = schedule_svc.list(params.copy())
        SchedulesInfo(schedule_vos, total_count)

        self.assertEqual(len(schedule_vos), 1)
        self.assertIsInstance(schedule_vos[0], Schedule)
        self.assertEqual(total_count, 1)
Exemple #4
0
 def list(self, params):
     return ScheduleFactory.build_batch(10, **params), 10