Exemple #1
0
    def test_update_schedule(self, *args):
        new_schedule_vo = ScheduleFactory(domain_id=self.domain_id)

        params = {
            'schedule_id': new_schedule_vo.storage_id,
            'schedule': {
                'cron': '*/5 * * * *'
            },
            'tags': {
                'update_key': 'update_value'
            },
            'domain_id': self.domain_id
        }

        self.transaction.method = 'update'
        schedule_svc = ScheduleService(transaction=self.transaction)
        schedule_vo = schedule_svc.update(params.copy())

        print_data(schedule_vo.to_dict(), 'test_update_schedule')
        ScheduleInfo(schedule_vo)

        self.assertIsInstance(schedule_vo, Schedule)
        self.assertEqual(new_schedule_vo.storage_id, schedule_vo.schedule_id)
        self.assertIsInstance(schedule_vo.schedule, Scheduled)
        self.assertEqual(schedule_vo.schedule.cron, params['schedule']['cron'])
        self.assertEqual(params['tags'], utils.tags_to_dict(schedule_vo.tags))
        self.assertEqual(params['domain_id'], schedule_vo.domain_id)
Exemple #2
0
    def test_update_schedule_with_wrong_schedule_option(self, *args):
        new_schedule_vo = ScheduleFactory(domain_id=self.domain_id)

        params = {
            'schedule_id': new_schedule_vo.storage_id,
            'schedule': {
                'cron': '*/5 * * * *',
                'interval': 5
            },
            'tags': {
                'update_key': 'update_value'
            },
            'domain_id': self.domain_id
        }

        self.transaction.method = 'update'
        schedule_svc = ScheduleService(transaction=self.transaction)

        with self.assertRaises(ERROR_SCHEDULE_OPTION):
            schedule_vo = schedule_svc.update(params.copy())