def test_rsync_publisher(target_url, called_command, tmpdir, mocker, env): publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse(target_url) ssh_path = join(output_path, "ssh") mock_popen = mocker.patch("lektor.publisher.portable_popen") publisher.get_command(target_url, str(ssh_path), credentials=None) assert mock_popen.called assert mock_popen.call_args[0] == (called_command,)
def test_rsync_command_username_in_url(tmpdir, mocker, env): output_path = tmpdir.mkdir("output") publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse("http://[email protected]") ssh_path = tmpdir.mkdir("ssh") mock_popen = mocker.patch("lektor.publisher.portable_popen") command = publisher.get_command(target_url, str(ssh_path), credentials=None) assert mock_popen.called assert mock_popen.call_args[0] == ( ["rsync", "-rclzv", "--exclude=.lektor", str(output_path) + "/", "[email protected]:/"], )
def test_rsync_command_delete_no(tmpdir, mocker, env): output_path = tmpdir.mkdir("output") publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse("http://example.com?delete=no") ssh_path = tmpdir.mkdir("ssh") mock_popen = mocker.patch("lektor.publisher.portable_popen") command = publisher.get_command(target_url, str(ssh_path), credentials=None) assert mock_popen.called assert mock_popen.call_args[0] == ([ 'rsync', '-rclzv', '--exclude=.lektor', str(output_path) + '/', 'example.com:/' ],)
def test_rsync_command_exclude_escape_file_name_reverse_string(tmpdir, mocker, env): output_path = tmpdir.mkdir("output") publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse('http://example.com?exclude="file name"') ssh_path = tmpdir.mkdir("ssh") mock_popen = mocker.patch("lektor.publisher.portable_popen") command = publisher.get_command(target_url, str(ssh_path), credentials=None) assert mock_popen.called assert mock_popen.call_args[0] == ([ 'rsync', '-rclzv', '--exclude=.lektor', '--exclude', '"file name"', str(output_path) + '/', 'example.com:/' ],)
def test_rsync_command(tmpdir, mocker, env): output_path = tmpdir.mkdir("output") publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse("http://example.com") ssh_path = tmpdir.mkdir("ssh") mock_popen = mocker.patch("lektor.publisher.portable_popen") command = publisher.get_command(target_url, str(ssh_path), credentials=None) assert mock_popen.called assert mock_popen.call_args[0] == ([ 'rsync', '-rclzv', '--exclude=.lektor', str(output_path) + '/', 'example.com:/' ],)
def test_rsync_command_credentials(tmpdir, mocker, env): output_path = tmpdir.mkdir("output") publisher = RsyncPublisher(env, str(output_path)) target_url = url_parse("http://example.com") ssh_path = tmpdir.mkdir("ssh") credentials = { "username": "******", "password": "******", } mock_popen = mocker.patch("lektor.publisher.portable_popen") command = publisher.get_command(target_url, str(ssh_path), credentials) assert mock_popen.called assert mock_popen.call_args[0] == ([ 'rsync', '-rclzv', '--exclude=.lektor', str(output_path) + '/', '[email protected]:/' ], )