def test_refresh_term_data(self): """Refreshes term data without duplicate key violation in db.""" CanvasJob(simply_yield).run() std_commit(allow_test_environment=True) CanvasJob(simply_yield).run() std_commit(allow_test_environment=True)
def test_authorized(self, client, admin_session): """Admin can access job_history.""" CanvasJob(simply_yield).run() CanvasJob(simply_yield).run() job_history = self._api_job_history(client) assert len(job_history) > 1 for event in job_history: assert event['failed'] is False assert event['startedAt'] assert 'finishedAt' in event
def _set_up_and_run_jobs(): Job.create(job_schedule_type='day_at', job_schedule_value='15:00', key='kaltura') Job.create(job_schedule_type='day_at', job_schedule_value='04:30', key='queued_emails') Job.create(job_schedule_type='day_at', job_schedule_value='22:00', key='house_keeping') Job.create(job_schedule_type='minutes', job_schedule_value='120', key='instructor_emails') Job.create(job_schedule_type='minutes', job_schedule_value='120', key='invitations') Job.create(disabled=True, job_schedule_type='minutes', job_schedule_value='120', key='admin_emails') Job.create(job_schedule_type='day_at', job_schedule_value='16:00', key='canvas') Job.create(disabled=True, job_schedule_type='minutes', job_schedule_value='5', key='doomed_to_fail') background_job_manager.start(app) HouseKeepingJob(app_context=simply_yield).run() CanvasJob(app_context=simply_yield).run() std_commit(allow_test_environment=True)
def test_section_with_canvas_course_sites(self, client, admin_session): """Canvas course site information is included in the API.""" CanvasJob(simply_yield).run() api_json = api_get_course( client, term_id=self.term_id, section_id=section_with_canvas_course_sites, ) assert len(api_json['canvasCourseSites']) == 3
def test_alert_on_job_failure(self): admin_uid = app.config['EMAIL_DIABLO_ADMIN_UID'] email_count = _get_email_count(admin_uid) # No alert on happy job. CanvasJob(simply_yield).run() assert _get_email_count(admin_uid) == email_count # Alert on sad job. all_jobs = Job.get_all(include_disabled=True) doomed_job = next( (j for j in all_jobs if j.key == DoomedToFailure.key())) # Make sure job is enabled Job.update_disabled(job_id=doomed_job.id, disable=False) std_commit(allow_test_environment=True) DoomedToFailure(simply_yield).run() # Failure alerts do not go through the queue. assert _get_email_count(admin_uid) == email_count + 1
def _run_jobs(): CanvasJob(app_context=app.app_context).run_with_app_context() std_commit(allow_test_environment=True)