# Path: ndscheduler/corescheduler/constants.py
# DEFAULT_JOBS_TABLENAME = 'scheduler_jobs'
# DEFAULT_EXECUTIONS_TABLENAME = 'scheduler_execution'
# DEFAULT_AUDIT_LOGS_TABLENAME = 'scheduler_jobauditlog'
# DEFAULT_THREAD_POOL_SIZE = 4
# DEFAULT_JOB_MAX_INSTANCES = 3
# DEFAULT_JOB_COALESCE = True
# DEFAULT_TIMEZONE = 'UTC'
# DEFAULT_JOB_MISFIRE_GRACE_SEC = 3600
# JOB_ARGS = 5
# EXECUTION_STATUS_SCHEDULED = 0
# EXECUTION_STATUS_RUNNING = 1
# EXECUTION_STATUS_STOPPING = 2
# EXECUTION_STATUS_STOPPED = 3
# EXECUTION_STATUS_FAILED = 4
# EXECUTION_STATUS_SUCCEEDED = 5
# EXECUTION_STATUS_TIMEOUT = 6
# EXECUTION_STATUS_SCHEDULED_ERROR = 7
# EXECUTION_STATUS_DICT = {
#     EXECUTION_STATUS_SCHEDULED: 'scheduled',
#     EXECUTION_STATUS_RUNNING: 'running',
#     EXECUTION_STATUS_STOPPING: 'stopping',
#     EXECUTION_STATUS_STOPPED: 'stopped',
#     EXECUTION_STATUS_FAILED: 'failed',
#     EXECUTION_STATUS_SUCCEEDED: 'succeeded',
#     EXECUTION_STATUS_TIMEOUT: 'timeout',
#     EXECUTION_STATUS_SCHEDULED_ERROR: 'scheduled error'
# }
# AUDIT_LOG_ADDED = 0
# AUDIT_LOG_MODIFIED = 1
# AUDIT_LOG_DELETED = 2
# AUDIT_LOG_PAUSED = 3
# AUDIT_LOG_RESUMED = 4
# AUDIT_LOG_CUSTOM_RUN = 5
# AUDIT_LOG_DICT = {
#     AUDIT_LOG_ADDED: 'added',
#     AUDIT_LOG_MODIFIED: 'modified',
#     AUDIT_LOG_DELETED: 'deleted',
#     AUDIT_LOG_PAUSED: 'paused',
#     AUDIT_LOG_RESUMED: 'resumed',
#     AUDIT_LOG_CUSTOM_RUN: 'custom_run'
# }
# 
# 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/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/executions.py
# class Handler(base.BaseHandler):
#     def _get_execution(self, execution_id):
#     def get_execution(self, execution_id):
#     def get_execution_yield(self, execution_id):
#     def _get_executions(self):
#     def get_executions(self):
#     def get_executions_yield(self):
#     def get(self, execution_id=None):
#     def _run_job(self, job_id):
#     def run_job(self, job_id):
#     def run_job_yield(self, job_id):
#     def post(self, job_id):
#     def delete(self, job_id):


import datetime
import json
import tornado.testing
from ndscheduler.corescheduler import constants
from ndscheduler.corescheduler import scheduler_manager
from ndscheduler.server import server
from ndscheduler.server.handlers import executions
"""Unit tests for executions endpoint."""





def mock_get_executions_yield(self):
    return_json = self._get_executions()
    self.finish(return_json)


def mock_get_execution_yield(self, execution_id):
    return_json = self._get_execution(execution_id)
    self.finish(return_json)


class ExecutionsTest(tornado.testing.AsyncHTTPTestCase):

    def setUp(self, *args, **kwargs):
        super(ExecutionsTest, self).setUp(*args, **kwargs)
        self.server.start_scheduler()
        self.EXECUTIONS_URL = '/api/v1/executions'
        self.old_get_executions_yield = executions.Handler.get_executions_yield

# Path: ndscheduler/corescheduler/constants.py
# DEFAULT_JOBS_TABLENAME = 'scheduler_jobs'
# DEFAULT_EXECUTIONS_TABLENAME = 'scheduler_execution'
# DEFAULT_AUDIT_LOGS_TABLENAME = 'scheduler_jobauditlog'
# DEFAULT_THREAD_POOL_SIZE = 4
# DEFAULT_JOB_MAX_INSTANCES = 3
# DEFAULT_JOB_COALESCE = True
# DEFAULT_TIMEZONE = 'UTC'
# DEFAULT_JOB_MISFIRE_GRACE_SEC = 3600
# JOB_ARGS = 5
# EXECUTION_STATUS_SCHEDULED = 0
# EXECUTION_STATUS_RUNNING = 1
# EXECUTION_STATUS_STOPPING = 2
# EXECUTION_STATUS_STOPPED = 3
# EXECUTION_STATUS_FAILED = 4
# EXECUTION_STATUS_SUCCEEDED = 5
# EXECUTION_STATUS_TIMEOUT = 6
# EXECUTION_STATUS_SCHEDULED_ERROR = 7
# EXECUTION_STATUS_DICT = {
#     EXECUTION_STATUS_SCHEDULED: 'scheduled',
#     EXECUTION_STATUS_RUNNING: 'running',
#     EXECUTION_STATUS_STOPPING: 'stopping',
#     EXECUTION_STATUS_STOPPED: 'stopped',
#     EXECUTION_STATUS_FAILED: 'failed',
#     EXECUTION_STATUS_SUCCEEDED: 'succeeded',
#     EXECUTION_STATUS_TIMEOUT: 'timeout',
#     EXECUTION_STATUS_SCHEDULED_ERROR: 'scheduled error'
# }
# AUDIT_LOG_ADDED = 0
# AUDIT_LOG_MODIFIED = 1
# AUDIT_LOG_DELETED = 2
# AUDIT_LOG_PAUSED = 3
# AUDIT_LOG_RESUMED = 4
# AUDIT_LOG_CUSTOM_RUN = 5
# AUDIT_LOG_DICT = {
#     AUDIT_LOG_ADDED: 'added',
#     AUDIT_LOG_MODIFIED: 'modified',
#     AUDIT_LOG_DELETED: 'deleted',
#     AUDIT_LOG_PAUSED: 'paused',
#     AUDIT_LOG_RESUMED: 'resumed',
#     AUDIT_LOG_CUSTOM_RUN: 'custom_run'
# }
# 
# 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/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/executions.py
# class Handler(base.BaseHandler):
#     def _get_execution(self, execution_id):
#     def get_execution(self, execution_id):
#     def get_execution_yield(self, execution_id):
#     def _get_executions(self):
#     def get_executions(self):
#     def get_executions_yield(self):
#     def get(self, execution_id=None):
#     def _run_job(self, job_id):
#     def run_job(self, job_id):
#     def run_job_yield(self, job_id):
#     def post(self, job_id):
#     def delete(self, job_id):


# Path: ndscheduler/server/handlers/executions_test.py
import datetime
import json
import tornado.testing
from ndscheduler.corescheduler import constants
from ndscheduler.corescheduler import scheduler_manager
from ndscheduler.server import server
from ndscheduler.server.handlers import executions

"""Unit tests for executions endpoint."""





def mock_get_executions_yield(self):
    return_json = self._get_executions()
    self.finish(return_json)


def mock_get_execution_yield(self, execution_id):
    return_json = self._get_execution(execution_id)
    self.finish(return_json)


class ExecutionsTest(tornado.testing.AsyncHTTPTestCase):

    def setUp(self, *args, **kwargs):
        super(ExecutionsTest, self).setUp(*args, **kwargs)
        self.server.start_scheduler()
        self.EXECUTIONS_URL = '/api/v1/executions'
        self.old_get_executions_yield = executions.Handler.get_executions_yield

        self.old_get_execution_yield = executions.Handler.get_execution_yield