Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Jul 18, 2024
1 parent f6d413a commit 38d41e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
19 changes: 4 additions & 15 deletions tests/cli/schains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_)

Expand Down Expand Up @@ -153,30 +153,19 @@ 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 = []
resp_mock = response_mock(
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 = {
Expand Down
3 changes: 2 additions & 1 deletion tests/core/core_schains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 38d41e2

Please sign in to comment.