# Path: arq/cli.py
# @click.command('arq')
# @click.version_option(VERSION, '-V', '--version', prog_name='arq')
# @click.argument('worker-settings', type=str, required=True)
# @click.option('--burst/--no-burst', default=None, help=burst_help)
# @click.option('--check', is_flag=True, help=health_check_help)
# @click.option('--watch', type=click.Path(exists=True, dir_okay=True, file_okay=False), help=watch_help)
# @click.option('-v', '--verbose', is_flag=True, help=verbose_help)
# def cli(*, worker_settings: str, burst: bool, check: bool, watch: str, verbose: bool) -> None:
#     """
#     Job queues in python with asyncio and redis.
# 
#     CLI to run the arq worker.
#     """
#     sys.path.append(os.getcwd())
#     worker_settings_ = cast('WorkerSettingsType', import_string(worker_settings))
#     logging.config.dictConfig(default_log_config(verbose))
# 
#     if check:
#         exit(check_health(worker_settings_))
#     else:
#         kwargs = {} if burst is None else {'burst': burst}
#         if watch:
#             asyncio.run(watch_reload(watch, worker_settings_))
#         else:
#             run_worker(worker_settings_, **kwargs)


import pytest
from click.testing import CliRunner
from arq.cli import cli



async def foobar(ctx):
    return 42


class WorkerSettings:
    burst = True
    functions = [foobar]


def test_help():
    runner = CliRunner()
    result = runner.invoke(cli, ['--help'])
    assert result.exit_code == 0
    assert result.output.startswith('Usage: arq [OPTIONS] WORKER_SETTINGS\n')


def test_run(cancel_remaining_task, mocker, loop):
    mocker.patch('asyncio.get_event_loop', lambda: loop)
    runner = CliRunner()

# Path: arq/cli.py
# @click.command('arq')
# @click.version_option(VERSION, '-V', '--version', prog_name='arq')
# @click.argument('worker-settings', type=str, required=True)
# @click.option('--burst/--no-burst', default=None, help=burst_help)
# @click.option('--check', is_flag=True, help=health_check_help)
# @click.option('--watch', type=click.Path(exists=True, dir_okay=True, file_okay=False), help=watch_help)
# @click.option('-v', '--verbose', is_flag=True, help=verbose_help)
# def cli(*, worker_settings: str, burst: bool, check: bool, watch: str, verbose: bool) -> None:
#     """
#     Job queues in python with asyncio and redis.
# 
#     CLI to run the arq worker.
#     """
#     sys.path.append(os.getcwd())
#     worker_settings_ = cast('WorkerSettingsType', import_string(worker_settings))
#     logging.config.dictConfig(default_log_config(verbose))
# 
#     if check:
#         exit(check_health(worker_settings_))
#     else:
#         kwargs = {} if burst is None else {'burst': burst}
#         if watch:
#             asyncio.run(watch_reload(watch, worker_settings_))
#         else:
#             run_worker(worker_settings_, **kwargs)


# Path: tests/test_cli.py
import pytest
from click.testing import CliRunner
from arq.cli import cli




async def foobar(ctx):
    return 42


class WorkerSettings:
    burst = True
    functions = [foobar]


def test_help():
    runner = CliRunner()
    result = runner.invoke(cli, ['--help'])
    assert result.exit_code == 0
    assert result.output.startswith('Usage: arq [OPTIONS] WORKER_SETTINGS\n')


def test_run(cancel_remaining_task, mocker, loop):
    mocker.patch('asyncio.get_event_loop', lambda: loop)
    runner = CliRunner()

    result = runner.invoke(cli, ['tests.test_cli.WorkerSettings'])