Skip to content

Commit

Permalink
Fix update_sync test
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Oct 11, 2024
1 parent 5ca8eeb commit fc308fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
3 changes: 0 additions & 3 deletions node_cli/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ def init_sync(
@check_inited
@check_user
def update_sync(env_filepath: str, unsafe_ok: bool = False) -> None:
if not unsafe_ok and not is_update_safe():
error_msg = 'Cannot update safely'
error_exit(error_msg, exit_code=CLIExitCodes.UNSAFE_UPDATE)
logger.info('Node update started')
configure_firewall_rules()
env = get_node_env(env_filepath, sync_node=True)
Expand Down
19 changes: 2 additions & 17 deletions tests/cli/sync_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
from node_cli.configs import SKALE_DIR, NODE_DATA_PATH
from node_cli.core.node_options import NodeOptions
from node_cli.cli.sync_node import _init_sync, _update_sync
from node_cli.utils.exit_codes import CLIExitCodes
from node_cli.utils.helper import init_default_logger

from tests.helper import run_command, safe_update_api_response, subprocess_run_mock
from tests.helper import run_command, subprocess_run_mock
from tests.resources_test import BIG_DISK_SIZE

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -107,18 +106,4 @@ def test_update_sync(mocked_g_config):
'node_cli.utils.decorators.is_node_inited', return_value=True
):
result = run_command(_update_sync, ['./tests/test-env', '--yes'])
assert result.exit_code == CLIExitCodes.UNSAFE_UPDATE
assert 'Cannot update safely' in result.output

with mock.patch(
'node_cli.utils.helper.requests.get', return_value=safe_update_api_response()
):
result = run_command(_update_sync, ['./tests/test-env', '--yes'])
assert result.exit_code == 0

with mock.patch(
'node_cli.utils.helper.requests.get', return_value=safe_update_api_response(False)
):
result = run_command(_update_sync, ['./tests/test-env', '--yes'])
assert result.exit_code == CLIExitCodes.UNSAFE_UPDATE
assert 'Cannot update safely' in result.output
assert result.exit_code == 0

0 comments on commit fc308fa

Please sign in to comment.