# Path: ndscheduler/corescheduler/scheduler_manager.py
# class SchedulerManager:
#     def __init__(self, scheduler_class_path,
#                  datastore_class_path,
#                  db_config=None,
#                  db_tablenames=None,
#                  job_coalesce=constants.DEFAULT_JOB_COALESCE,
#                  job_misfire_grace_sec=constants.DEFAULT_JOB_MISFIRE_GRACE_SEC,
#                  job_max_instances=constants.DEFAULT_JOB_MAX_INSTANCES,
#                  thread_pool_size=constants.DEFAULT_THREAD_POOL_SIZE,
#                  timezone=constants.DEFAULT_TIMEZONE):
#     def get_datastore(self):
#     def start(self):
#     def stop(self):
#     def add_job(self, job_class_string, name, pub_args=None, month=None,
#                 day_of_week=None, day=None, hour=None, minute=None, **kwargs):
#     def pause_job(self, job_id):
#     def get_job(self, job_id):
#     def get_jobs(self):
#     def get_job_task_class(self, job):
#     def remove_job(self, job_id):
#     def resume_job(self, job_id):
#     def modify_job(self, job_id, **kwargs):
# 
# Path: ndscheduler/corescheduler/utils.py
# def import_from_path(path):
# def get_current_datetime():
# def get_job_name(job):
# def get_job_args(job):
# def get_job_kwargs(job):
# def get_cron_strings(job):
# def generate_uuid():
# def get_stacktrace():
# def get_hostname():
# def get_pid():
# def get_datastore_instance(datastore_class_path, db_config=None, db_tablenames=None):
# 
# Path: ndscheduler/server/server.py
# class SchedulerServer:
#     VERSION = 'v1'
#         URLS = [
#             # Index page
#             (r'/', index.Handler),
# 
#             # APIs
#             (r'/api/%s/jobs' % self.VERSION, jobs.Handler),
#             (r'/api/%s/jobs/(.*)' % self.VERSION, jobs.Handler),
#             (r'/api/%s/executions' % self.VERSION, executions.Handler),
#             (r'/api/%s/executions/(.*)' % self.VERSION, executions.Handler),
#             (r'/api/%s/logs' % self.VERSION, audit_logs.Handler),
#         ]
#     def __init__(self, scheduler_instance):
#     def start_scheduler(self):
#     def post_scheduler_start(self):
#     def stop_scheduler(self):
#     def post_scheduler_stop(self):
#     def signal_handler(cls, signal, frame):
#     def run(cls):
# 
# Path: ndscheduler/server/handlers/jobs.py
# class Handler(base.BaseHandler):
#     def _get_jobs(self):
#     def _build_job_dict(self, job):
#     def get_jobs(self):
#     def get_jobs_yield(self):
#     def _get_job(self, job_id):
#     def get_job(self, job_id):
#     def get_job_yield(self, job_id):
#     def get(self, job_id=None):
#     def post(self):
#     def _delete_job(self, job_id):
#     def delete_job(self, job_id):
#     def delete_job_yield(self, job_id):
#     def delete(self, job_id):
#     def _generate_description_for_item(self, old_job, new_job, item):
#     def _generate_description_for_modify(self, old_job, new_job):
#     def _modify_job(self, job_id):
#     def modify_job(self, job_id):
#     def modify_job_yield(self, job_id):
#     def put(self, job_id):
#     def patch(self, job_id):
#     def options(self, job_id):
#     def _validate_post_data(self):


import json
import tornado.testing
from ndscheduler.corescheduler import scheduler_manager
from ndscheduler.corescheduler import utils
from ndscheduler.server import server
from ndscheduler.server.handlers import jobs
        self.assertEqual(response.code, 200)

        response = self.fetch(self.JOBS_URL + '?sync=true')
        return_info = json.loads(response.body.decode())
        self.assertEqual(len(return_info['jobs']), 0)

    def test_modify_job(self):
        headers = {'Content-Type': 'application/json; charset=UTF-8'}
        data = {
            'job_class_string': 'hello.world',
            'name': 'hello world job',
            'minute': '*/5'}
        response = self.fetch(self.JOBS_URL, method='POST', headers=headers,
                              body=json.dumps(data))
        return_info = json.loads(response.body.decode())
        self.assertTrue('job_id' in return_info)
        self.assertEqual(len(return_info['job_id']), 32)
        job = self.scheduler.get_job(return_info['job_id'])
        self.assertEqual(utils.get_job_name(job), data['job_class_string'])
        self.assertEqual(job.name, data['name'])

        headers = {'Content-Type': 'application/json; charset=UTF-8'}
        data = {
            'job_class_string': 'hello.world!!!!',
            'name': 'hello world job~~~~',
            'minute': '*/20'}
        response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'] + '?sync=true',
                              method='PUT', headers=headers, body=json.dumps(data))
        self.assertEqual(response.code, 200)
        job = self.scheduler.get_job(return_info['job_id'])

# Path: ndscheduler/corescheduler/scheduler_manager.py
# class SchedulerManager:
#     def __init__(self, scheduler_class_path,
#                  datastore_class_path,
#                  db_config=None,
#                  db_tablenames=None,
#                  job_coalesce=constants.DEFAULT_JOB_COALESCE,
#                  job_misfire_grace_sec=constants.DEFAULT_JOB_MISFIRE_GRACE_SEC,
#                  job_max_instances=constants.DEFAULT_JOB_MAX_INSTANCES,
#                  thread_pool_size=constants.DEFAULT_THREAD_POOL_SIZE,
#                  timezone=constants.DEFAULT_TIMEZONE):
#     def get_datastore(self):
#     def start(self):
#     def stop(self):
#     def add_job(self, job_class_string, name, pub_args=None, month=None,
#                 day_of_week=None, day=None, hour=None, minute=None, **kwargs):
#     def pause_job(self, job_id):
#     def get_job(self, job_id):
#     def get_jobs(self):
#     def get_job_task_class(self, job):
#     def remove_job(self, job_id):
#     def resume_job(self, job_id):
#     def modify_job(self, job_id, **kwargs):
# 
# Path: ndscheduler/corescheduler/utils.py
# def import_from_path(path):
# def get_current_datetime():
# def get_job_name(job):
# def get_job_args(job):
# def get_job_kwargs(job):
# def get_cron_strings(job):
# def generate_uuid():
# def get_stacktrace():
# def get_hostname():
# def get_pid():
# def get_datastore_instance(datastore_class_path, db_config=None, db_tablenames=None):
# 
# Path: ndscheduler/server/server.py
# class SchedulerServer:
#     VERSION = 'v1'
#         URLS = [
#             # Index page
#             (r'/', index.Handler),
# 
#             # APIs
#             (r'/api/%s/jobs' % self.VERSION, jobs.Handler),
#             (r'/api/%s/jobs/(.*)' % self.VERSION, jobs.Handler),
#             (r'/api/%s/executions' % self.VERSION, executions.Handler),
#             (r'/api/%s/executions/(.*)' % self.VERSION, executions.Handler),
#             (r'/api/%s/logs' % self.VERSION, audit_logs.Handler),
#         ]
#     def __init__(self, scheduler_instance):
#     def start_scheduler(self):
#     def post_scheduler_start(self):
#     def stop_scheduler(self):
#     def post_scheduler_stop(self):
#     def signal_handler(cls, signal, frame):
#     def run(cls):
# 
# Path: ndscheduler/server/handlers/jobs.py
# class Handler(base.BaseHandler):
#     def _get_jobs(self):
#     def _build_job_dict(self, job):
#     def get_jobs(self):
#     def get_jobs_yield(self):
#     def _get_job(self, job_id):
#     def get_job(self, job_id):
#     def get_job_yield(self, job_id):
#     def get(self, job_id=None):
#     def post(self):
#     def _delete_job(self, job_id):
#     def delete_job(self, job_id):
#     def delete_job_yield(self, job_id):
#     def delete(self, job_id):
#     def _generate_description_for_item(self, old_job, new_job, item):
#     def _generate_description_for_modify(self, old_job, new_job):
#     def _modify_job(self, job_id):
#     def modify_job(self, job_id):
#     def modify_job_yield(self, job_id):
#     def put(self, job_id):
#     def patch(self, job_id):
#     def options(self, job_id):
#     def _validate_post_data(self):


# Path: ndscheduler/server/handlers/jobs_test.py
import json
import tornado.testing
from ndscheduler.corescheduler import scheduler_manager
from ndscheduler.corescheduler import utils
from ndscheduler.server import server
from ndscheduler.server.handlers import jobs

        self.assertEqual(response.code, 200)

        response = self.fetch(self.JOBS_URL + '?sync=true')
        return_info = json.loads(response.body.decode())
        self.assertEqual(len(return_info['jobs']), 0)

    def test_modify_job(self):
        headers = {'Content-Type': 'application/json; charset=UTF-8'}
        data = {
            'job_class_string': 'hello.world',
            'name': 'hello world job',
            'minute': '*/5'}
        response = self.fetch(self.JOBS_URL, method='POST', headers=headers,
                              body=json.dumps(data))
        return_info = json.loads(response.body.decode())
        self.assertTrue('job_id' in return_info)
        self.assertEqual(len(return_info['job_id']), 32)
        job = self.scheduler.get_job(return_info['job_id'])
        self.assertEqual(utils.get_job_name(job), data['job_class_string'])
        self.assertEqual(job.name, data['name'])

        headers = {'Content-Type': 'application/json; charset=UTF-8'}
        data = {
            'job_class_string': 'hello.world!!!!',
            'name': 'hello world job~~~~',
            'minute': '*/20'}
        response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'] + '?sync=true',
                              method='PUT', headers=headers, body=json.dumps(data))
        self.assertEqual(response.code, 200)
        job = self.scheduler.get_job(return_info['job_id'])

        self.assertEqual(utils.get_job_name(job), data['job_class_string'])