def test_reload_configured_schedule(self, app, client): post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', credentials(app), { 'hour': 12, 'minute': 30 }, ) post_basic_auth( client, '/api/schedule/job_resync_canvas_snapshots', credentials(app), {}, ) response = post_basic_auth( client, '/api/schedule/reload', credentials(app), ) assert response.status_code == 200 jobs = response.json assert len(jobs) == 14 sync_job = next(job for job in jobs if job['id'] == 'job_sync_canvas_snapshots') assert sync_job['trigger'] == "cron[hour='1', minute='0']" resync_job = next(job for job in jobs if job['id'] == 'job_resync_canvas_snapshots') assert '01:40:00' in resync_job['nextRun']
def test_bad_authentication(self, client, api_path_authenticated): """Refuse a request with bad authentication.""" response = post_basic_auth( client, api_path_authenticated, ('arrant', 'knave'), ) assert response.status_code == 401
def test_bad_authentication(self, app, client): """Refuse a request with bad authentication.""" response = post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', ('arrant', 'knave'), ) assert response.status_code == 401
def test_unknown_job_id(self, app, client): """Handles unknown job id.""" response = post_basic_auth( client, '/api/schedule/job_churn_butter', credentials(app), ) assert response.status_code == 400
def test_unknown_cron_param(self, app, client): """Handles unknown cron params.""" response = post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', credentials(app), {'h': 'j'}, ) assert response.status_code == 400
def test_background_job_status(self, app, client, metadata_db): """Returns a well-formed response.""" response = post_basic_auth( client, '/api/admin/background_job_status', credentials(app), ) assert response.status_code == 200 assert response.json == []
def test_requires_key(self, app, client): """Requires key parameter.""" response = post_basic_auth( client, '/api/job/sync_file_to_s3', credentials(app), {'url': 'https://foo.instructure.com'}, ) assert response.status_code == 400 assert response.json['message'] == 'Required "key" parameter missing.'
def test_requires_url(self, app, client): """Requires url parameter.""" response = post_basic_auth( client, '/api/job/sync_file_to_s3', credentials(app), {'key': 'requests/requests.tar.gz'}, ) assert response.status_code == 400 assert response.json['message'] == 'Required "url" parameter missing.'
def test_delete_job(self, app, client): """Deletes obsolete job definition from schedule.""" post_basic_auth( client, '/api/schedule/reload', credentials(app), ) jobs = client.get('/api/schedule').json assert len(jobs) == 17 assert next((job for job in jobs if job['id'] == 'job_generate_all_tables'), None) is not None response = delete_basic_auth( client, '/api/schedule/job_generate_all_tables', credentials(app), ) assert response.status_code == 200 jobs = response.json assert len(jobs) == 16 assert next((job for job in jobs if job['id'] == 'job_generate_all_tables'), None) is None
def test_job_reschedule(self, app, client, scheduler): """Reschedules a job.""" response = post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', credentials(app), {'hour': 12, 'minute': 30}, ) assert response.status_code == 200 assert response.json['trigger'] == "cron[hour='12', minute='30']" assert '12:30:00' in response.json['nextRun']
def test_job_pause_resume(self, app, client, scheduler): """Pauses and resumes a job.""" response = post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', credentials(app), {}, ) assert response.status_code == 200 assert response.json['trigger'] == "cron[hour='1', minute='0']" assert response.json['nextRun'] is None response = post_basic_auth( client, '/api/schedule/job_sync_canvas_snapshots', credentials(app), {'hour': 1, 'minute': 0}, ) assert response.status_code == 200 assert response.json['trigger'] == "cron[hour='1', minute='0']" assert '01:00:00' in response.json['nextRun']
def test_status(self, app, client): """Returns job status.""" response = post_basic_auth( client, '/api/job/sync_file_to_s3', credentials(app), { 'url': 'https://foo.instructure.com', 'key': 'requests/requests.tar.gz' }, ) assert response.status_code == 200 assert response.json['status'] == 'started'
def test_update_job_args(self, app, client, scheduler): """Updates job args.""" jobs = client.get('/api/schedule').json feed_job = next(j for j in jobs if j['id'] == 'job_generate_current_term_feeds') assert feed_job['args'] == { 'backfill_new_students': True, 'term_id': '2178' } response = post_basic_auth( client, '/api/schedule/job_generate_current_term_feeds/args', credentials(app), {'term_id': '2182'}, ) assert response.status_code == 200 jobs = client.get('/api/schedule').json feed_job = next(j for j in jobs if j['id'] == 'job_generate_current_term_feeds') assert feed_job['args'] == { 'backfill_new_students': True, 'term_id': '2182' }
def test_status(self, app, client, api_path_no_params): """Return job status.""" response = post_basic_auth(client, api_path_no_params, credentials(app)) assert response.status_code == 200 assert response.json['status'] == 'started'