#!/usr/bin/env python3
"""
Auto-generated CLI tests for folder commands

Generated by: tests/generators/test_generator.py
DO NOT EDIT MANUALLY - Regenerate with: python tests/generators/test_generator.py

This file provides comprehensive coverage of folder CLI commands, options,
and parameter combinations. Tests are automatically generated by introspecting
the Click command structure.
"""

import subprocess
import os

# Set testing environment variable
os.environ["N8N_DEPLOY_TESTING"] = "1"

CLI_COMMAND = ["./n8n-deploy"]


def test_folder_auth_help():
    """Test folder  auth --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "auth", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder auth --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_auth_data_dir_valid_path():
    """Test folder  auth with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "auth", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder auth --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_auth_skip_ssl_verify_flag():
    """Test folder  auth with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "auth", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder auth --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_auth_with_positional_args():
    """Test folder  auth with positional arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "auth", "test_server_name"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder auth test_server_name\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_auth_missing_required_args():
    """Test folder  auth with missing required arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "auth"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder auth\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Error:" in result.stdout or "Error:" in result.stderr, (
        f"Expected 'Error:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_list_help():
    """Test folder  list --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "list", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder list --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_list_no_args():
    """Test folder  list with no arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "list"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder list\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_list_output_json_flag():
    """Test folder  list with --output-json flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "list", "--output-json"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder list --output-json\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_list_data_dir_valid_path():
    """Test folder  list with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "list", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder list --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_list_skip_ssl_verify_flag():
    """Test folder  list with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "list", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder list --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_help():
    """Test folder  map --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_direction_push():
    """Test folder  map with --direction=push"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map", "--direction", "push"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --direction push\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_direction_pull():
    """Test folder  map with --direction=pull"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map", "--direction", "pull"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --direction pull\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_direction_bidirectional():
    """Test folder  map with --direction=bidirectional"""
    result = subprocess.run(
        CLI_COMMAND + ["folder", "map", "--direction", "bidirectional"], capture_output=True, text=True, timeout=60
    )
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --direction bidirectional\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_data_dir_valid_path():
    """Test folder  map with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_skip_ssl_verify_flag():
    """Test folder  map with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_with_positional_args():
    """Test folder  map with positional arguments"""
    result = subprocess.run(
        CLI_COMMAND + ["folder", "map", "/tmp/test_file.json", "test_n8n_folder"], capture_output=True, text=True, timeout=60
    )
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map /tmp/test_file.json test_n8n_folder\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_map_missing_required_args():
    """Test folder  map with missing required arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "map"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder map\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Error:" in result.stdout or "Error:" in result.stderr, (
        f"Expected 'Error:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_mappings_help():
    """Test folder  mappings --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "mappings", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder mappings --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_mappings_no_args():
    """Test folder  mappings with no arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "mappings"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder mappings\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_mappings_output_json_flag():
    """Test folder  mappings with --output-json flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "mappings", "--output-json"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder mappings --output-json\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_mappings_data_dir_valid_path():
    """Test folder  mappings with valid --data-dir"""
    result = subprocess.run(
        CLI_COMMAND + ["folder", "mappings", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60
    )
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder mappings --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_help():
    """Test folder  pull --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "pull", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_dry_run_flag():
    """Test folder  pull with --dry-run flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "pull", "--dry-run"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull --dry-run\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_data_dir_valid_path():
    """Test folder  pull with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "pull", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_skip_ssl_verify_flag():
    """Test folder  pull with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "pull", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_with_positional_args():
    """Test folder  pull with positional arguments"""
    result = subprocess.run(
        CLI_COMMAND + ["folder", "pull", "test_n8n_folder", "/tmp/test_file.json"], capture_output=True, text=True, timeout=60
    )
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull test_n8n_folder /tmp/test_file.json\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_pull_missing_required_args():
    """Test folder  pull with missing required arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "pull"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder pull\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Error:" in result.stdout or "Error:" in result.stderr, (
        f"Expected 'Error:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_help():
    """Test folder  push --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_create_folder_flag():
    """Test folder  push with --create-folder flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push", "--create-folder"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push --create-folder\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_dry_run_flag():
    """Test folder  push with --dry-run flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push", "--dry-run"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push --dry-run\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_data_dir_valid_path():
    """Test folder  push with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_skip_ssl_verify_flag():
    """Test folder  push with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_with_positional_args():
    """Test folder  push with positional arguments"""
    result = subprocess.run(
        CLI_COMMAND + ["folder", "push", "/tmp/test_file.json", "test_n8n_folder"], capture_output=True, text=True, timeout=60
    )
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push /tmp/test_file.json test_n8n_folder\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_push_missing_required_args():
    """Test folder  push with missing required arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "push"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder push\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Error:" in result.stdout or "Error:" in result.stderr, (
        f"Expected 'Error:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_sync_help():
    """Test folder  sync --help"""
    result = subprocess.run(CLI_COMMAND + ["folder", "sync", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder sync --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_folder_sync_no_args():
    """Test folder  sync with no arguments"""
    result = subprocess.run(CLI_COMMAND + ["folder", "sync"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder sync\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_sync_dry_run_flag():
    """Test folder  sync with --dry-run flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "sync", "--dry-run"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder sync --dry-run\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_sync_data_dir_valid_path():
    """Test folder  sync with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["folder", "sync", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder sync --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_folder_sync_skip_ssl_verify_flag():
    """Test folder  sync with --skip-ssl-verify flag"""
    result = subprocess.run(CLI_COMMAND + ["folder", "sync", "--skip-ssl-verify"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: folder sync --skip-ssl-verify\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
