diff --git a/src/pytest_celery/vendors/memcached/fixtures.py b/src/pytest_celery/vendors/memcached/fixtures.py index d471430e..2c8c5e2d 100644 --- a/src/pytest_celery/vendors/memcached/fixtures.py +++ b/src/pytest_celery/vendors/memcached/fixtures.py @@ -32,6 +32,14 @@ def celery_memcached_backend(default_memcached_backend: MemcachedContainer) -> M @pytest.fixture def default_memcached_backend_cls() -> type[MemcachedContainer]: + """Default Memcached backend container class. Override to apply custom + configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[MemcachedContainer]: API for managing the vendor's container. + """ return MemcachedContainer @@ -47,14 +55,38 @@ def default_memcached_backend_cls() -> type[MemcachedContainer]: @pytest.fixture def default_memcached_backend_env(default_memcached_backend_cls: type[MemcachedContainer]) -> dict: + """Environment variables for this vendor. + + Args: + default_memcached_backend_cls (type[MemcachedContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Items to pass to the container's environment. + """ return default_memcached_backend_cls.env() @pytest.fixture def default_memcached_backend_image(default_memcached_backend_cls: type[MemcachedContainer]) -> str: + """Docker image for this vendor. + + Args: + default_memcached_backend_cls (type[MemcachedContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Docker image name. + """ return default_memcached_backend_cls.image() @pytest.fixture def default_memcached_backend_ports(default_memcached_backend_cls: type[MemcachedContainer]) -> dict: + """Port bindings for this vendor. + + Args: + default_memcached_backend_cls (type[MemcachedContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Port bindings. + """ return default_memcached_backend_cls.ports() diff --git a/src/pytest_celery/vendors/rabbitmq/fixtures.py b/src/pytest_celery/vendors/rabbitmq/fixtures.py index 9a3f6623..b0111ec6 100644 --- a/src/pytest_celery/vendors/rabbitmq/fixtures.py +++ b/src/pytest_celery/vendors/rabbitmq/fixtures.py @@ -32,6 +32,14 @@ def celery_rabbitmq_broker(default_rabbitmq_broker: RabbitMQContainer) -> Rabbit @pytest.fixture def default_rabbitmq_broker_cls() -> type[RabbitMQContainer]: + """Default RabbitMQ broker container class. Override to apply custom + configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[RabbitMQContainer]: API for managing the vendor's container. + """ return RabbitMQContainer @@ -47,14 +55,38 @@ def default_rabbitmq_broker_cls() -> type[RabbitMQContainer]: @pytest.fixture def default_rabbitmq_broker_env(default_rabbitmq_broker_cls: type[RabbitMQContainer]) -> dict: + """Environment variables for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RabbitMQContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Items to pass to the container's environment. + """ return default_rabbitmq_broker_cls.env() @pytest.fixture def default_rabbitmq_broker_image(default_rabbitmq_broker_cls: type[RabbitMQContainer]) -> str: + """Sets the image name for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RabbitMQContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Docker image name. + """ return default_rabbitmq_broker_cls.image() @pytest.fixture def default_rabbitmq_broker_ports(default_rabbitmq_broker_cls: type[RabbitMQContainer]) -> dict: + """Port bindings for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RabbitMQContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Port bindings. + """ return default_rabbitmq_broker_cls.ports() diff --git a/src/pytest_celery/vendors/redis/backend/fixtures.py b/src/pytest_celery/vendors/redis/backend/fixtures.py index d4978e23..dfacf281 100644 --- a/src/pytest_celery/vendors/redis/backend/fixtures.py +++ b/src/pytest_celery/vendors/redis/backend/fixtures.py @@ -32,6 +32,14 @@ def celery_redis_backend(default_redis_backend: RedisContainer) -> RedisTestBack @pytest.fixture def default_redis_backend_cls() -> type[RedisContainer]: + """Default Redis backend container class. Override to apply custom + configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[RedisContainer]: API for managing the vendor's container. + """ return RedisContainer @@ -48,14 +56,38 @@ def default_redis_backend_cls() -> type[RedisContainer]: @pytest.fixture def default_redis_backend_env(default_redis_backend_cls: type[RedisContainer]) -> dict: + """Environment variables for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Items to pass to the container's environment. + """ return default_redis_backend_cls.env() @pytest.fixture def default_redis_backend_image(default_redis_backend_cls: type[RedisContainer]) -> str: + """Sets the image name for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Docker image name. + """ return default_redis_backend_cls.image() @pytest.fixture def default_redis_backend_ports(default_redis_backend_cls: type[RedisContainer]) -> dict: + """Port bindings for this vendor. + + Args: + default_redis_backend_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Port bindings. + """ return default_redis_backend_cls.ports() diff --git a/src/pytest_celery/vendors/redis/broker/fixtures.py b/src/pytest_celery/vendors/redis/broker/fixtures.py index 9debc1e9..96d50df8 100644 --- a/src/pytest_celery/vendors/redis/broker/fixtures.py +++ b/src/pytest_celery/vendors/redis/broker/fixtures.py @@ -32,6 +32,14 @@ def celery_redis_broker(default_redis_broker: RedisContainer) -> RedisTestBroker @pytest.fixture def default_redis_broker_cls() -> type[RedisContainer]: + """Default Redis broker container class. Override to apply custom + configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[RedisContainer]: API for managing the vendor's container. + """ return RedisContainer @@ -48,14 +56,38 @@ def default_redis_broker_cls() -> type[RedisContainer]: @pytest.fixture def default_redis_broker_env(default_redis_broker_cls: type[RedisContainer]) -> dict: + """Environment variables for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Items to pass to the container's environment. + """ return default_redis_broker_cls.env() @pytest.fixture def default_redis_broker_image(default_redis_broker_cls: type[RedisContainer]) -> str: + """Sets the image name for this vendor. + + Args: + default_rabbitmq_broker_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Docker image name. + """ return default_redis_broker_cls.image() @pytest.fixture def default_redis_broker_ports(default_redis_broker_cls: type[RedisContainer]) -> dict: + """Port bindings for this vendor. + + Args: + default_redis_broker_cls (type[RedisContainer]): See also: :ref:`vendor-class`. + + Returns: + dict: Port bindings. + """ return default_redis_broker_cls.ports() diff --git a/src/pytest_celery/vendors/worker/fixtures.py b/src/pytest_celery/vendors/worker/fixtures.py index 4f22ede7..0fe57a8c 100644 --- a/src/pytest_celery/vendors/worker/fixtures.py +++ b/src/pytest_celery/vendors/worker/fixtures.py @@ -48,16 +48,39 @@ def celery_setup_worker( @pytest.fixture def default_worker_cls() -> type[CeleryTestWorker]: + """Default worker class. Override to apply custom configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[CeleryTestWorker]: API for managing the vendor's node. + """ return CeleryTestWorker @pytest.fixture def default_worker_container_cls() -> type[CeleryWorkerContainer]: + """Default worker container class. Override to apply custom configuration + globally. + + See also: :ref:`vendor-class`. + + Returns: + type[CeleryWorkerContainer]: API for managing the vendor's container. + """ return CeleryWorkerContainer @pytest.fixture(scope="session") def default_worker_container_session_cls() -> type[CeleryWorkerContainer]: + """Default worker container session class. Override to apply custom + configuration globally. + + See also: :ref:`vendor-class`. + + Returns: + type[CeleryWorkerContainer]: API for managing the vendor's container. + """ return CeleryWorkerContainer @@ -88,21 +111,53 @@ def default_worker_container_session_cls() -> type[CeleryWorkerContainer]: @pytest.fixture(scope="session") def default_worker_celery_version(default_worker_container_session_cls: type[CeleryWorkerContainer]) -> str: + """Celery version for this worker. + + Args: + default_worker_container_session_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Celery version. + """ return default_worker_container_session_cls.version() @pytest.fixture(scope="session") def default_worker_celery_log_level(default_worker_container_session_cls: type[CeleryWorkerContainer]) -> str: + """Log level for this worker. + + Args: + default_worker_container_session_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Log level. + """ return default_worker_container_session_cls.log_level() @pytest.fixture(scope="session") def default_worker_celery_worker_name(default_worker_container_session_cls: type[CeleryWorkerContainer]) -> str: + """Name of the worker. + + Args: + default_worker_container_session_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Worker name. + """ return default_worker_container_session_cls.worker_name() @pytest.fixture(scope="session") def default_worker_celery_worker_queue(default_worker_container_session_cls: type[CeleryWorkerContainer]) -> str: + """Worker queue for this worker. + + Args: + default_worker_container_session_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + str: Worker queue. + """ return default_worker_container_session_cls.worker_queue() @@ -111,6 +166,15 @@ def default_worker_env( default_worker_container_cls: type[CeleryWorkerContainer], celery_worker_cluster_config: dict, ) -> dict: + """Environment variables for this worker. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + celery_worker_cluster_config (dict): Broker & Backend clusters configuration. + + Returns: + dict: Items to pass to the container's environment. + """ return default_worker_container_cls.env(celery_worker_cluster_config) @@ -123,6 +187,33 @@ def default_worker_initial_content( default_worker_signals: set, default_worker_app: Celery, ) -> dict: + """Initial content for this worker's volume. + + This is applied on a worker container when using the following volume configuration: + + .. code-block:: python + + default_worker_container = container( + ... + volumes={"{default_worker_volume.name}": DEFAULT_WORKER_VOLUME}, + ... + ) + + .. note:: + + Move volumes may be added additionally. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + default_worker_app_module (ModuleType): App module to inject. + default_worker_utils_module (ModuleType): Utils module to inject. + default_worker_tasks (set): Tasks modules to inject. + default_worker_signals (set): Signals modules to inject. + default_worker_app (Celery): Celery app to initialize the worker with. + + Returns: + dict: Initial volume content (dict of files). + """ return default_worker_container_cls.initial_content( app_module=default_worker_app_module, utils_module=default_worker_utils_module, @@ -134,24 +225,64 @@ def default_worker_initial_content( @pytest.fixture def default_worker_app_module(default_worker_container_cls: type[CeleryWorkerContainer]) -> ModuleType: + """App module for this worker. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + ModuleType: App module. + """ return default_worker_container_cls.app_module() @pytest.fixture def default_worker_utils_module(default_worker_container_cls: type[CeleryWorkerContainer]) -> ModuleType: + """Utils module for this worker. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + ModuleType: Utils module. + """ return default_worker_container_cls.utils_module() @pytest.fixture def default_worker_tasks(default_worker_container_cls: type[CeleryWorkerContainer]) -> set: + """Tasks modules set for this worker. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + set: Tasks modules. + """ return default_worker_container_cls.tasks_modules() @pytest.fixture def default_worker_signals(default_worker_container_cls: type[CeleryWorkerContainer]) -> set: + """Signals modules set for this worker. + + Args: + default_worker_container_cls (type[CeleryWorkerContainer]): See also: :ref:`vendor-class`. + + Returns: + set: Signals modules. + """ return default_worker_container_cls.signals_modules() @pytest.fixture def default_worker_app(celery_setup_app: Celery) -> Celery: + """Celery app instance for this worker. + + Args: + celery_setup_app (Celery): See also: :ref:`vendor-class`. + + Returns: + Celery: Celery app instance. + """ return celery_setup_app