diff --git a/cicada/lib/scheduler.py b/cicada/lib/scheduler.py index 8721c18..47c7e55 100644 --- a/cicada/lib/scheduler.py +++ b/cicada/lib/scheduler.py @@ -153,7 +153,7 @@ def insert_schedule_details(db_cur, schedule_details): if schedule_details["schedule_description"] is not None: sqlquery = sqlquery + " ,'" + str(schedule_details["schedule_description"]) + "'" if schedule_details["server_id"] is None: - sqlquery = sqlquery + " ,(SELECT MIN(server_id) FROM servers WHERE is_enabled=1)" + sqlquery = sqlquery + " ,(SELECT MAX(server_id) FROM servers WHERE is_enabled=1)" else: sqlquery = sqlquery + " ," + str(schedule_details["server_id"]) if schedule_details["schedule_order"] is not None: diff --git a/pyproject.toml b/pyproject.toml index 471948f..a8fb973 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] requires = ["setuptools >= 20.0"] build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 120 diff --git a/setup.py b/setup.py index e07a69e..8f6c72c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="cicada", - version="0.5.1", + version="0.6.0", description="Lightweight, agent-based, distributed scheduler", long_description=long_description, long_description_content_type="text/markdown", @@ -20,19 +20,19 @@ install_requires=[ "psycopg2-binary==2.9.5", "pyyaml==6.0", - "croniter==1.3.8", - "tabulate==0.9.0", - "slack-sdk==3.19.5", - "backoff==2.2.1", + "croniter==1.3", + "tabulate==0.9", + "slack-sdk==3.19", + "backoff==2.2", ], extras_require={ "dev": [ - "pytest==7.2.0", - "pytest-cov==4.0.0", - "pytest-mock==3.10.0", - "black==22.12.0", - "flake8==6.0.0", - "freezegun==1.2.2", + "pytest==7.3", + "pytest-cov==4.0", + "pytest-mock==3.10", + "black==22.12", + "flake8==6.0", + "freezegun==1.2", ] }, entry_points={"console_scripts": ["cicada=cicada.cli:main"]}, diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_functional_main.py b/tests/test_functional_main.py index a2f65c2..996d590 100644 --- a/tests/test_functional_main.py +++ b/tests/test_functional_main.py @@ -241,7 +241,9 @@ def test_exec_schedule(): assert query_result >= 1 -def test_exec_schedule_send_alert_if_returncode_not_0_and_config_has_setting_for_all(mocker): # noqa +def test_exec_schedule_send_alert_if_returncode_not_0_and_config_has_setting_for_all( + mocker, +): # noqa """test sending alert if returncode is not 0, and config setting is *""" return_code = choice(list(range(-100, 0)) + list(range(1, 100))) @@ -256,7 +258,7 @@ def test_exec_schedule_send_alert_if_returncode_not_0_and_config_has_setting_for slack: channel: foo_channel returncodes_alert: * - """ + """, ) with TemporaryDirectory() as temp_dir: for file_content in definitions_contents: @@ -268,17 +270,21 @@ def test_exec_schedule_send_alert_if_returncode_not_0_and_config_has_setting_for mocked_slack.assert_called_once_with("FOO_SCHEDULE_ID", "FOO_LOG_ID", return_code, None, None) -def test_exec_schedule_send_alert_if_returncode_not_0_and_exists_in_config(mocker): # noqa +def test_exec_schedule_send_alert_if_returncode_not_0_and_exists_in_config( + mocker, +): # noqa """test sending alert if returncode is not 0, and it is included in the config setting""" return_code = choice([1, 13, -15]) mocked_slack = mocks_for_alert_test(return_code, mocker=mocker) with TemporaryDirectory() as temp_dir: with open(f"{temp_dir}/definitions.yml", "w", encoding="utf-8") as definitions_file: - definitions_file.write(""" + definitions_file.write( + """ slack: channel: foo_channel - returncodes_alert: [1, 13, -15]""") + returncodes_alert: [1, 13, -15]""" + ) mocker.patch("os.path.join", return_value=f"{temp_dir}/definitions.yml") exec_schedule.main("FOO_SCHEDULE_ID", "FOO_DB") @@ -292,10 +298,12 @@ def test_exec_schedule_not_send_alert_if_returncode_0_but_not_in_config(mocker): mocked_slack = mocks_for_alert_test(return_code=return_code, mocker=mocker) with TemporaryDirectory() as temp_dir: with open(f"{temp_dir}/definitions.yml", "w", encoding="utf-8") as definitions_file: - definitions_file.write(""" + definitions_file.write( + """ slack: channel: foo_channel - returncodes_alert: [13, -15]""") + returncodes_alert: [13, -15]""" + ) mocker.patch("os.path.join", return_value=f"{temp_dir}/definitions.yml") exec_schedule.main("FOO_SCHEDULE_ID", "FOO_DB")