diff --git a/ndscheduler/__init__.py b/ndscheduler/__init__.py index 5730cfa..5136b73 100644 --- a/ndscheduler/__init__.py +++ b/ndscheduler/__init__.py @@ -80,11 +80,11 @@ def __init__(self, *args, **kwargs): error = ImportError( 'Could not import settings "%s" (Is it on sys.path?): %s' % (settings_module_path, e)) - logger.warn(error) + logger.warning(error) except KeyError: # NOTE: This is arguably an EnvironmentError, but that causes # problems with Python's interactive help. - logger.warn( + logger.warning( ('Environment variable %s is undefined. ' 'Use default settings for now.') % ENVIRONMENT_VARIABLE) diff --git a/ndscheduler/core/datastore/providers/base_test.py b/ndscheduler/core/datastore/providers/base_test.py index 878806d..f5b2d58 100644 --- a/ndscheduler/core/datastore/providers/base_test.py +++ b/ndscheduler/core/datastore/providers/base_test.py @@ -5,6 +5,7 @@ from ndscheduler import constants from ndscheduler.core.datastore.providers import base +from apscheduler.schedulers.blocking import BlockingScheduler class SimpleDatastore(base.DatastoreBase): @@ -20,7 +21,9 @@ def get_time_isoformat_from_db(self, time_object): class DatastoreBaseTest(unittest.TestCase): def setUp(self): + fake_scheduler = BlockingScheduler() self.store = SimpleDatastore.get_instance() + self.store.start(fake_scheduler, None) def test_add_execution_get_execution(self): eid = '12345' diff --git a/ndscheduler/core/scheduler_manager_test.py b/ndscheduler/core/scheduler_manager_test.py index 112c1c2..24dfca6 100644 --- a/ndscheduler/core/scheduler_manager_test.py +++ b/ndscheduler/core/scheduler_manager_test.py @@ -45,21 +45,21 @@ def test_add_job_get_job(self): self.assertEqual(utils.get_job_kwargs(job), {'languages': 'en-us'}) # Year - self.assertEquals(str(job.trigger.fields[0]), '*') + self.assertEqual(str(job.trigger.fields[0]), '*') # Month - self.assertEquals(str(job.trigger.fields[1]), month) + self.assertEqual(str(job.trigger.fields[1]), month) # day of month - self.assertEquals(str(job.trigger.fields[2]), day) + self.assertEqual(str(job.trigger.fields[2]), day) # week - self.assertEquals(str(job.trigger.fields[3]), '*') + self.assertEqual(str(job.trigger.fields[3]), '*') # day of week - self.assertEquals(str(job.trigger.fields[4]), day_of_week) + self.assertEqual(str(job.trigger.fields[4]), day_of_week) # hour - self.assertEquals(str(job.trigger.fields[5]), hour) + self.assertEqual(str(job.trigger.fields[5]), hour) # minute - self.assertEquals(str(job.trigger.fields[6]), minute) + self.assertEqual(str(job.trigger.fields[6]), minute) # second - self.assertEquals(str(job.trigger.fields[7]), '0') + self.assertEqual(str(job.trigger.fields[7]), '0') @tornado.testing.gen_test def test_add_job_modify_job(self): @@ -81,7 +81,7 @@ def test_add_job_modify_job(self): job_class_string = 'hello.world1234' args = ['5', '6', '7'] name = 'hello world 3' - month = '*/12' + month = '*/6' # non-blocking operation self.scheduler.modify_job(job_id, name=name, job_class_string=job_class_string, @@ -89,9 +89,9 @@ def test_add_job_modify_job(self): # blocking operation job = self.scheduler.get_job(job_id) - self.assertEquals(job.name, name) + self.assertEqual(job.name, name) arguments = [job_class_string, job_id] arguments += args - self.assertEquals(list(job.args), arguments) - self.assertEquals(str(job.trigger.fields[1]), month) + self.assertEqual(list(job.args), arguments) + self.assertEqual(str(job.trigger.fields[1]), month) diff --git a/ndscheduler/server/handlers/executions_test.py b/ndscheduler/server/handlers/executions_test.py index 78de10c..592959f 100644 --- a/ndscheduler/server/handlers/executions_test.py +++ b/ndscheduler/server/handlers/executions_test.py @@ -55,9 +55,9 @@ def test_get_execution(self): datastore.add_execution(execution1['eid'], execution1['job_id'], execution1['state']) response = self.fetch(self.EXECUTIONS_URL + '/%s?sync=true' % execution1['eid']) return_info = json.loads(response.body.decode()) - self.assertEquals(return_info['execution_id'], execution1['eid']) - self.assertEquals(return_info['state'], - constants.EXECUTION_STATUS_DICT[execution1['state']]) + self.assertEqual(return_info['execution_id'], execution1['eid']) + self.assertEqual(return_info['state'], + constants.EXECUTION_STATUS_DICT[execution1['state']]) def test_get_execution1(self): datastore = self.scheduler.get_datastore() @@ -73,4 +73,4 @@ def test_get_execution1(self): response = self.fetch(self.EXECUTIONS_URL + '?time_range_end=%s' % ( two_minutes_later.isoformat())) return_info = json.loads(response.body.decode()) - self.assertEquals(return_info['executions'][0]['execution_id'], execution1['eid']) + self.assertEqual(return_info['executions'][0]['execution_id'], execution1['eid']) diff --git a/ndscheduler/server/handlers/jobs_test.py b/ndscheduler/server/handlers/jobs_test.py index dba727a..b7b981d 100644 --- a/ndscheduler/server/handlers/jobs_test.py +++ b/ndscheduler/server/handlers/jobs_test.py @@ -72,7 +72,7 @@ def test_add_job_success(self): body=json.dumps(data)) return_info = json.loads(response.body.decode()) self.assertTrue('job_id' in return_info) - self.assertEquals(len(return_info['job_id']), 32) + self.assertEqual(len(return_info['job_id']), 32) job = self.scheduler.get_job(return_info['job_id']) self.assertEqual(job.name, data['name']) @@ -83,14 +83,14 @@ def test_add_job_failed(self): 'name': 'hello world job'} response = self.fetch(self.JOBS_URL, method='POST', headers=headers, body=json.dumps(data)) - self.assertEquals(response.code, 400) + self.assertEqual(response.code, 400) data = { 'job_class_string': 'hello.world', 'minute': '*/5'} response = self.fetch(self.JOBS_URL, method='POST', headers=headers, body=json.dumps(data)) - self.assertEquals(response.code, 400) + self.assertEqual(response.code, 400) def test_pause_resume_job(self): headers = {'Content-Type': 'application/json; charset=UTF-8'} @@ -102,14 +102,14 @@ def test_pause_resume_job(self): body=json.dumps(data)) return_info = json.loads(response.body.decode()) self.assertTrue('job_id' in return_info) - self.assertEquals(len(return_info['job_id']), 32) + self.assertEqual(len(return_info['job_id']), 32) response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'], method='PATCH', body='{}') - self.assertEquals(response.code, 200) + self.assertEqual(response.code, 200) response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'], method='OPTIONS') - self.assertEquals(response.code, 200) + self.assertEqual(response.code, 200) def test_get_jobs(self): headers = {'Content-Type': 'application/json; charset=UTF-8'} @@ -121,15 +121,15 @@ def test_get_jobs(self): body=json.dumps(data)) return_info = json.loads(response.body.decode()) self.assertTrue('job_id' in return_info) - self.assertEquals(len(return_info['job_id']), 32) + self.assertEqual(len(return_info['job_id']), 32) response = self.fetch(self.JOBS_URL + '?sync=true') return_info = json.loads(response.body.decode()) - self.assertEquals(len(return_info['jobs']), 1) + self.assertEqual(len(return_info['jobs']), 1) job = return_info['jobs'][0] - self.assertEquals(job['job_class_string'], data['job_class_string']) - self.assertEquals(job['name'], data['name']) - self.assertEquals(job['minute'], data['minute']) + self.assertEqual(job['job_class_string'], data['job_class_string']) + self.assertEqual(job['name'], data['name']) + self.assertEqual(job['minute'], data['minute']) def test_delete_job(self): headers = {'Content-Type': 'application/json; charset=UTF-8'} @@ -141,15 +141,15 @@ def test_delete_job(self): body=json.dumps(data)) return_info = json.loads(response.body.decode()) self.assertTrue('job_id' in return_info) - self.assertEquals(len(return_info['job_id']), 32) + self.assertEqual(len(return_info['job_id']), 32) response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'] + '?sync=true', method='DELETE') - self.assertEquals(response.code, 200) + self.assertEqual(response.code, 200) response = self.fetch(self.JOBS_URL + '?sync=true') return_info = json.loads(response.body.decode()) - self.assertEquals(len(return_info['jobs']), 0) + self.assertEqual(len(return_info['jobs']), 0) def test_modify_job(self): headers = {'Content-Type': 'application/json; charset=UTF-8'} @@ -161,19 +161,19 @@ def test_modify_job(self): body=json.dumps(data)) return_info = json.loads(response.body.decode()) self.assertTrue('job_id' in return_info) - self.assertEquals(len(return_info['job_id']), 32) + self.assertEqual(len(return_info['job_id']), 32) job = self.scheduler.get_job(return_info['job_id']) - self.assertEquals(utils.get_job_name(job), data['job_class_string']) - self.assertEquals(job.name, data['name']) + 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': '*/100'} + 'minute': '*/20'} response = self.fetch(self.JOBS_URL + '/' + return_info['job_id'] + '?sync=true', method='PUT', headers=headers, body=json.dumps(data)) - self.assertEquals(response.code, 200) + self.assertEqual(response.code, 200) job = self.scheduler.get_job(return_info['job_id']) - self.assertEquals(utils.get_job_name(job), data['job_class_string']) - self.assertEquals(job.name, data['name']) + self.assertEqual(utils.get_job_name(job), data['job_class_string']) + self.assertEqual(job.name, data['name']) diff --git a/setup.py b/setup.py index 8b01c22..a949787 100644 --- a/setup.py +++ b/setup.py @@ -75,18 +75,16 @@ def maybe_rm(path): extras_require={'python_version<"3.3"': ['funcsigs']}, tests_require=[ 'funcsigs', - 'mock == 1.1.2', + 'mock >= 1.1.2', 'nose', ], test_suite='nose.collector', install_requires=[ - # Note ndscheduler *only* works with 3.0.x. See the docs for more detail. - # https://apscheduler.readthedocs.io/en/latest/migration.html#from-v3-0-to-v3-2 - 'APScheduler == 3.0.0', - 'SQLAlchemy == 1.0.0', - 'future == 0.15.2', - 'tornado == 4.3.0', - 'python-dateutil == 2.2', + 'APScheduler >= 3.0.0', + 'SQLAlchemy >= 1.0.0', + 'future >= 0.15.2', + 'tornado < 6', + 'python-dateutil >= 2.2', ], classifiers=classifiers, cmdclass={'clean': CleanHook}, diff --git a/simple_scheduler/requirements.txt b/simple_scheduler/requirements.txt index 1a5677e..77964e2 100644 --- a/simple_scheduler/requirements.txt +++ b/simple_scheduler/requirements.txt @@ -3,7 +3,7 @@ # This apns library's release version still doesn't support python 3.5! git+git://github.com/djacobs/PyAPNs.git#egg=PyAPNs -requests == 2.9.1 +requests # Uncomment this if you want to use Postgres as datastore #