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)
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)