# Path: tests/functional/ucare_cli/helpers.py
# def arg_namespace(arguments_str):
#     return ucare_argparser().parse_args(arguments_str.split())
# 
# Path: pyuploadcare/ucare_cli/main.py
# def main(  # noqa: C901
#     arg_namespace=None, config_file_names=("~/.uploadcare", "uploadcare.ini")
# ):
#     if arg_namespace is None:
#         arg_namespace = ucare_argparser().parse_args()
# 
#     conf = load_config(arg_namespace, config_file_names)
# 
#     client = Uploadcare(**conf)
# 
#     if hasattr(arg_namespace, "func"):
#         try:
#             arg_namespace.func(arg_namespace, client)
#         except UploadcareException as exc:
#             pprint("ERROR: {0}".format(exc))


import os
import tempfile
import pytest
from tests.functional.ucare_cli.helpers import arg_namespace
from pyuploadcare.ucare_cli.main import main
    assert os.path.exists(sync_path)

    assert len(os.listdir(sync_path)) == 1


def test_sync_file_exists_and_replace_flag(sync_path):
    main(
        arg_namespace(
            f"--pub_key demopublickey --secret demosecretkey "
            f"sync --limit 1 --no-input {sync_path}"
        )
    )

    filename = os.listdir(sync_path)[0]
    filepath = os.path.join(sync_path, filename)
    created_time = os.path.getmtime(filepath)
    main(
        arg_namespace(
            f"--pub_key demopublickey --secret demosecretkey "
            f"sync --limit 1 --replace --no-input {sync_path}"
        )
    )
    assert os.path.getmtime(filepath) > created_time


def test_sync_uuids(sync_path, uploadcare):
    file_list = list(uploadcare.list_files(limit=2))
    uuids = [str(file.uuid) for file in file_list]

    main(

# Path: tests/functional/ucare_cli/helpers.py
# def arg_namespace(arguments_str):
#     return ucare_argparser().parse_args(arguments_str.split())
# 
# Path: pyuploadcare/ucare_cli/main.py
# def main(  # noqa: C901
#     arg_namespace=None, config_file_names=("~/.uploadcare", "uploadcare.ini")
# ):
#     if arg_namespace is None:
#         arg_namespace = ucare_argparser().parse_args()
# 
#     conf = load_config(arg_namespace, config_file_names)
# 
#     client = Uploadcare(**conf)
# 
#     if hasattr(arg_namespace, "func"):
#         try:
#             arg_namespace.func(arg_namespace, client)
#         except UploadcareException as exc:
#             pprint("ERROR: {0}".format(exc))


# Path: tests/integration/ucare_cli/test_sync_files.py
import os
import tempfile
import pytest
from tests.functional.ucare_cli.helpers import arg_namespace
from pyuploadcare.ucare_cli.main import main

    assert os.path.exists(sync_path)

    assert len(os.listdir(sync_path)) == 1


def test_sync_file_exists_and_replace_flag(sync_path):
    main(
        arg_namespace(
            f"--pub_key demopublickey --secret demosecretkey "
            f"sync --limit 1 --no-input {sync_path}"
        )
    )

    filename = os.listdir(sync_path)[0]
    filepath = os.path.join(sync_path, filename)
    created_time = os.path.getmtime(filepath)
    main(
        arg_namespace(
            f"--pub_key demopublickey --secret demosecretkey "
            f"sync --limit 1 --replace --no-input {sync_path}"
        )
    )
    assert os.path.getmtime(filepath) > created_time


def test_sync_uuids(sync_path, uploadcare):
    file_list = list(uploadcare.list_files(limit=2))
    uuids = [str(file.uuid) for file in file_list]

    main(

        arg_namespace(