def test_show(resource_alloc_config): resp_mock = response_mock(requests.codes.created) write_json(RESOURCE_ALLOCATION_FILEPATH, TEST_CONFIG) result = run_command_mock('node_cli.utils.helper.post_request', resp_mock, show) assert result.output == json.dumps(TEST_CONFIG, indent=4) + '\n' assert result.exit_code == 0
def test_check_user(mocked_g_config): @check_user def this_checks_user(): pass generate_g_config_file(GLOBAL_SKALE_DIR, GLOBAL_SKALE_CONF_FILEPATH) this_checks_user() write_json(GLOBAL_SKALE_CONF_FILEPATH, {'user': '******'}) with pytest.raises(SystemExit): this_checks_user()
def test_is_user_valid(mocked_g_config): generate_g_config_file(GLOBAL_SKALE_DIR, GLOBAL_SKALE_CONF_FILEPATH) assert is_user_valid() write_json(GLOBAL_SKALE_CONF_FILEPATH, {'user': '******'}) assert not is_user_valid() with mock.patch('os.path.expanduser', return_value='/root'): assert is_user_valid() assert not is_user_valid(allow_root=False)
def resource_alloc_config(): write_json(RESOURCE_ALLOCATION_FILEPATH, INITIAL_CONFIG) yield RESOURCE_ALLOCATION_FILEPATH os.remove(RESOURCE_ALLOCATION_FILEPATH)
def update_resource_allocation(disk_device: str, env_type: str) -> None: resource_allocation_config = compose_resource_allocation_config( disk_device, env_type) write_json(RESOURCE_ALLOCATION_FILEPATH, resource_allocation_config)
def test_read_g_config(mocked_g_config): write_json(GLOBAL_SKALE_CONF_FILEPATH, {'test': 1}) g_config = read_g_config(GLOBAL_SKALE_DIR, GLOBAL_SKALE_CONF_FILEPATH) assert g_config['test'] == 1
def test_get_g_conf_user(mocked_g_config): write_json(GLOBAL_SKALE_CONF_FILEPATH, {'user': '******'}) assert get_g_conf_user() == 'test_get_g_conf_user'