# 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/datastore/providers/sqlite.py
# class DatastoreSqlite(base.DatastoreBase):
# 
#     def get_db_url(self):
#         """Returns the db url to establish a SQLite connection, where db_config is passed in
#         on initialization as:
#         {
#             'file_path': 'an_absolute_file_path'
#         }
#         If 'file_path' is not passed in, an in-memory SQLite db is created.
#         :return: string db url
#         """
#         file_path = ''
#         if self.db_config and 'file_path' in self.db_config:
#             file_path = self.db_config['file_path']
#         return 'sqlite:///' + file_path
# 
#     def get_time_isoformat_from_db(self, time_object):
#         date = datetime.datetime.strptime(time_object, '%Y-%m-%d %H:%M:%S.%f')
#         date = pytz.utc.localize(date)
#         return date.isoformat()


import datetime
import unittest
from apscheduler.schedulers.blocking import BlockingScheduler
from ndscheduler.corescheduler import constants
from ndscheduler.corescheduler.datastore.providers.sqlite import DatastoreSqlite
        self.assertEqual(execution['execution_id'], eid)

    def test_update_execution_get_execution(self):
        eid = '12346'
        job_id = '321'
        self.store.add_execution(eid, job_id, state=constants.EXECUTION_STATUS_SCHEDULED)
        self.store.update_execution(eid, state=constants.EXECUTION_STATUS_RUNNING)
        execution = self.store.get_execution(eid)
        self.assertEqual(execution['execution_id'], eid)
        self.assertEqual(execution['state'],
                         constants.EXECUTION_STATUS_DICT[constants.EXECUTION_STATUS_RUNNING])

    def test_get_executions_by_time_interval(self):
        now = datetime.datetime.now()
        start_time = (now + datetime.timedelta(minutes=20)).isoformat()
        end_time = (now + datetime.timedelta(minutes=100)).isoformat()
        self.store.add_execution('12', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=5))
        self.store.add_execution('13', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=50))
        self.store.add_execution('14', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=70))
        self.store.add_execution('15', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=120))
        executions = self.store.get_executions(start_time, end_time)
        self.assertEqual(len(executions['executions']), 2)

    def test_add_audit_log_get_audit_logs(self):
        job_id = '234'
        job_name = 'asdfs'

# 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/datastore/providers/sqlite.py
# class DatastoreSqlite(base.DatastoreBase):
# 
#     def get_db_url(self):
#         """Returns the db url to establish a SQLite connection, where db_config is passed in
#         on initialization as:
#         {
#             'file_path': 'an_absolute_file_path'
#         }
#         If 'file_path' is not passed in, an in-memory SQLite db is created.
#         :return: string db url
#         """
#         file_path = ''
#         if self.db_config and 'file_path' in self.db_config:
#             file_path = self.db_config['file_path']
#         return 'sqlite:///' + file_path
# 
#     def get_time_isoformat_from_db(self, time_object):
#         date = datetime.datetime.strptime(time_object, '%Y-%m-%d %H:%M:%S.%f')
#         date = pytz.utc.localize(date)
#         return date.isoformat()


# Path: ndscheduler/corescheduler/datastore/base_test.py
import datetime
import unittest
from apscheduler.schedulers.blocking import BlockingScheduler
from ndscheduler.corescheduler import constants
from ndscheduler.corescheduler.datastore.providers.sqlite import DatastoreSqlite

        self.assertEqual(execution['execution_id'], eid)

    def test_update_execution_get_execution(self):
        eid = '12346'
        job_id = '321'
        self.store.add_execution(eid, job_id, state=constants.EXECUTION_STATUS_SCHEDULED)
        self.store.update_execution(eid, state=constants.EXECUTION_STATUS_RUNNING)
        execution = self.store.get_execution(eid)
        self.assertEqual(execution['execution_id'], eid)
        self.assertEqual(execution['state'],
                         constants.EXECUTION_STATUS_DICT[constants.EXECUTION_STATUS_RUNNING])

    def test_get_executions_by_time_interval(self):
        now = datetime.datetime.now()
        start_time = (now + datetime.timedelta(minutes=20)).isoformat()
        end_time = (now + datetime.timedelta(minutes=100)).isoformat()
        self.store.add_execution('12', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=5))
        self.store.add_execution('13', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=50))
        self.store.add_execution('14', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=70))
        self.store.add_execution('15', '34', state=constants.EXECUTION_STATUS_SCHEDULED,
                                 scheduled_time=now + datetime.timedelta(minutes=120))
        executions = self.store.get_executions(start_time, end_time)
        self.assertEqual(len(executions['executions']), 2)

    def test_add_audit_log_get_audit_logs(self):
        job_id = '234'
        job_name = 'asdfs'

        event = constants.AUDIT_LOG_ADDED