def test_creates_scripts_dir_in_destination_if_it_does_not_exist(connection_mock, *_): syno_config = create_syno_config_mock() run_remote_installation_commands(syno_config, Mock(), "/example/path", "") mock_methods = [calls[0] for calls in connection_mock.mock_calls] mock_calls = [calls[1] for calls in connection_mock.mock_calls] assert "run" in mock_methods[2] assert "mkdir -p /example/path" in mock_calls[2]
def test_opens_fabric_connection_with_correct_credentials( config_mock, connection_mock, *_ ): syno_config = create_syno_config_mock() run_remote_installation_commands(syno_config, Mock(), "", "") config_mock.assert_called_once_with( overrides={"sudo": {"password": "******"}} ) connection_mock.assert_called_once_with( host="host_mock", user="******", config=config_mock.return_value )
def test_deleted_zipped_file_after_extraction(connection_mock, os_path_mock, *_): os_path_mock.join.return_value = "processed/path/files.zip" syno_config = create_syno_config_mock() run_remote_installation_commands( syno_config, "/local/zipped/files.zip", "/example/path", "/absolute/example/path", ) mock_methods = [calls[0] for calls in connection_mock.mock_calls] mock_args = [args for args in connection_mock.mock_calls] assert "run" in mock_methods[5] assert "rm processed/path/files.zip" in mock_args[5][1]
def test_creates_transfers_zipped_files(connection_mock, *_): syno_config = create_syno_config_mock() run_remote_installation_commands( syno_config, "/local/zipped/files.zip", "/example/path", "/absolute/example/path", ) mock_methods = [calls[0] for calls in connection_mock.mock_calls] mock_args = [args for args in connection_mock.mock_calls] assert "put" in mock_methods[3] assert "/local/zipped/files.zip" in mock_args[3][1] assert {"remote": "/example/path"} == mock_args[3][2]
def test_runs_unzip_command_on_destination(connection_mock, os_path_mock, *_): os_path_mock.join.return_value = "processed/path/files.zip" syno_config = create_syno_config_mock() run_remote_installation_commands( syno_config, "/local/zipped/files.zip", "/example/path", "/absolute/example/path", ) mock_methods = [calls[0] for calls in connection_mock.mock_calls] mock_args = [args for args in connection_mock.mock_calls] assert "run" in mock_methods[4] assert ( "7z e processed/path/files.zip -o//absolute/example/path -aoa" in mock_args[4][1] )
@patch("synotools.commands.install.run_remote_installation_commands") @patch("synotools.commands.install.zip_folder") @patch( "synotools.commands.install.build_destination_paths", return_value=("/sftp/path/example", "/absolute/path/example"), ) @patch("synotools.commands.install.SynoConfig") def test_instances_required_configurations(syno_config_mock, *_): install_scripts() syno_config_mock.assert_called_once() @patch("synotools.commands.install.run_remote_installation_commands") @patch("synotools.commands.install.zip_folder") @patch("synotools.commands.install.SynoConfig", return_value=create_syno_config_mock()) @patch( "synotools.commands.install.build_destination_paths", return_value=("/sftp/path/example", "/absolute/path/example"), ) def test_builds_destination_paths_according_to_default_username( build_destination_paths_mock, *_): install_scripts() build_destination_paths_mock.assert_called_once_with("user_mock") @patch("synotools.commands.install.run_remote_installation_commands") @patch("synotools.commands.install.zip_folder") @patch("synotools.commands.install.SynoConfig", return_value=create_syno_config_mock())