From 38d41e23ec6994fd58ed5bdcee5dce2b1eeef26d Mon Sep 17 00:00:00 2001 From: badrogger Date: Thu, 18 Jul 2024 16:36:05 +0000 Subject: [PATCH] Fix tests --- tests/cli/schains_test.py | 19 ++++--------------- tests/core/core_schains_test.py | 3 ++- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/cli/schains_test.py b/tests/cli/schains_test.py index e2bd3669..6db4f21c 100644 --- a/tests/cli/schains_test.py +++ b/tests/cli/schains_test.py @@ -23,7 +23,7 @@ import requests from node_cli.configs import G_CONF_HOME -from tests.helper import response_mock, run_command_mock +from tests.helper import response_mock, run_command, run_command_mock from node_cli.cli.schains import (get_schain_config, ls, dkg, show_rules, repair, info_) @@ -153,7 +153,8 @@ def test_schain_rules(): assert result.output == ' IP range Port \n-----------------------------\n127.0.0.2 - 127.0.0.2 10000\n127.0.0.2 - 127.0.0.2 10001\nAll IPs 10002\nAll IPs 10003\n127.0.0.2 - 127.0.0.2 10004\n127.0.0.2 - 127.0.0.2 10005\nAll IPs 10007\nAll IPs 10008\nAll IPs 10009\n' # noqa -def test_repair(): +def test_repair(tmp_schains_dir): + os.mkdir(os.path.join(tmp_schains_dir, 'test-schain')) os.environ['TZ'] = 'Europe/London' time.tzset() payload = [] @@ -161,22 +162,10 @@ def test_repair(): requests.codes.ok, json_data={'payload': payload, 'status': 'ok'} ) - result = run_command_mock('node_cli.utils.helper.requests.post', resp_mock, repair, - ['test-schain', '--yes']) + result = run_command(repair, ['test-schain', '--yes']) assert result.output == 'Schain has been set for repair\n' assert result.exit_code == 0 - payload = ['error'] - resp_mock = response_mock( - requests.codes.ok, - json_data={'payload': payload, 'status': 'error'} - ) - result = run_command_mock('node_cli.utils.helper.requests.post', resp_mock, repair, - ['test-schain', '--yes']) - print(repr(result.output)) - assert result.exit_code == 3 - assert result.output == f'Command failed with following errors:\n--------------------------------------------------\nerror\n--------------------------------------------------\nYou can find more info in {G_CONF_HOME}.skale/.skale-cli-log/debug-node-cli.log\n' # noqa - def test_info(): payload = { diff --git a/tests/core/core_schains_test.py b/tests/core/core_schains_test.py index 29ef337a..0c27a7ad 100644 --- a/tests/core/core_schains_test.py +++ b/tests/core/core_schains_test.py @@ -17,12 +17,13 @@ def test_toggle_repair_mode(tmp_schains_dir): schain_folder = os.path.join(tmp_schains_dir, schain_name) os.mkdir(schain_folder) toggle_schain_repair_mode(schain_name) - schain_status_path = os.path.join(schain_folder, "node-cli.status") + schain_status_path = os.path.join(schain_folder, "node_cli.status") assert os.path.isfile(schain_status_path) assert read_json(schain_status_path) == { 'repair_ts': CURRENT_TIMESTAMP, 'schain_name': 'test_schain', + 'snapshot_from': None, } toggle_schain_repair_mode(schain_name, snapshot_from='127.0.0.1')