Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed pytest-lazy-fixture dependency #200

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ optional = true
pytest = "^7.4.4"
coverage = "^7.0.0"
pytest-sugar = { version = "^1.0.0", python = ">=3.8,<4.0" }
pytest-lazy-fixture = "^0.6.3"
pytest-cov = "^4.0.0"
pytest-xdist = "^3.1.0"
pytest-subtests = "^0.11.0"
Expand Down
29 changes: 12 additions & 17 deletions tests/integration/api/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_BACKEND
from pytest_celery import CELERY_BACKEND_CLUSTER
from pytest_celery import CeleryBackendCluster
from pytest_celery import CeleryTestBackend
from pytest_celery import CeleryTestCluster
from pytest_celery import CeleryTestNode
from tests.integration.api.test_base import BaseCluster
from tests.integration.api.test_base import BaseNodes


@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_BACKEND)])
class test_celey_test_backend:
def test_app(self, backend: CeleryTestBackend):
assert backend.app is None
class test_celey_test_backend(BaseNodes):
@pytest.fixture
def node(self, celery_backend: CeleryTestBackend) -> CeleryTestNode:
return celery_backend


@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BACKEND_CLUSTER)])
class test_celery_backend_cluster:
def test_app(self, cluster: CeleryBackendCluster):
backend: CeleryTestBackend
for backend in cluster:
assert backend.app is None

def test_config(self, cluster: CeleryBackendCluster):
expected_keys = {"urls", "host_urls"}
assert set(cluster.config().keys()) == expected_keys
class test_celery_backend_cluster(BaseCluster):
@pytest.fixture
def cluster(self, celery_backend_cluster: CeleryBackendCluster) -> CeleryTestCluster:
return celery_backend_cluster
21 changes: 14 additions & 7 deletions tests/integration/api/test_base.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CeleryTestCluster
from pytest_celery import CeleryTestNode
from pytest_celery import RedisTestBackend
from tests.defaults import ALL_CLUSTERS_FIXTURES
from tests.defaults import ALL_NODES_FIXTURES


@pytest.mark.parametrize("node", lazy_fixture(ALL_NODES_FIXTURES))
class test_celery_test_node:
class BaseNodes:
def test_ready(self, node: CeleryTestNode):
assert node.ready()

def test_app(self, node: CeleryTestNode):
assert node.app is None

def test_logs(self, node: CeleryTestNode):
node.logs()

Expand Down Expand Up @@ -62,10 +61,18 @@ def test_assert_log_does_not_exist(self, node: CeleryTestNode):
pass


@pytest.mark.parametrize("cluster", lazy_fixture(ALL_CLUSTERS_FIXTURES))
class test_celery_test_cluster:
class BaseCluster:
def test_ready(self, cluster: CeleryTestCluster):
assert cluster.ready()

def test_teardown(self, cluster: CeleryTestCluster):
cluster.teardown()

def test_app(self, cluster: CeleryTestCluster):
node: CeleryTestNode
for node in cluster:
assert node.app is None

def test_config(self, cluster: CeleryTestCluster):
expected_keys = {"urls", "host_urls"}
assert set(cluster.config().keys()) == expected_keys
29 changes: 12 additions & 17 deletions tests/integration/api/test_broker.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_BROKER
from pytest_celery import CELERY_BROKER_CLUSTER
from pytest_celery import CeleryBrokerCluster
from pytest_celery import CeleryTestBroker
from pytest_celery import CeleryTestCluster
from pytest_celery import CeleryTestNode
from tests.integration.api.test_base import BaseCluster
from tests.integration.api.test_base import BaseNodes


@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_BROKER)])
class test_celery_test_broker:
def test_app(self, broker: CeleryTestBroker):
assert broker.app is None
class test_celery_test_broker(BaseNodes):
@pytest.fixture
def node(self, celery_broker: CeleryTestBroker) -> CeleryTestNode:
return celery_broker


@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_BROKER_CLUSTER)])
class test_celery_broker_cluster:
def test_app(self, cluster: CeleryBrokerCluster):
broker: CeleryTestBroker
for broker in cluster:
assert broker.app is None

def test_config(self, cluster: CeleryBrokerCluster):
expected_keys = {"urls", "host_urls"}
assert set(cluster.config().keys()) == expected_keys
class test_celery_broker_cluster(BaseCluster):
@pytest.fixture
def cluster(self, celery_broker_cluster: CeleryBrokerCluster) -> CeleryTestCluster:
return celery_broker_cluster
8 changes: 6 additions & 2 deletions tests/integration/api/test_container.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CeleryTestContainer
from tests.defaults import ALL_COMPONENTS_FIXTURES


@pytest.mark.parametrize("container", lazy_fixture(ALL_COMPONENTS_FIXTURES))
@pytest.fixture
def container(request):
return request.getfixturevalue(request.param)


@pytest.mark.parametrize("container", ALL_COMPONENTS_FIXTURES, indirect=["container"])
class test_celery_test_container:
def test_client(self, container: CeleryTestContainer):
assert container.client
Expand Down
61 changes: 34 additions & 27 deletions tests/integration/api/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,55 @@

import pytest
from celery import Celery
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_WORKER
from pytest_celery import CELERY_WORKER_CLUSTER
from pytest_celery import CeleryTestCluster
from pytest_celery import CeleryTestNode
from pytest_celery import CeleryTestWorker
from pytest_celery import CeleryWorkerCluster
from pytest_celery import CeleryWorkerContainer
from tests.integration.api.test_base import BaseCluster
from tests.integration.api.test_base import BaseNodes


@pytest.mark.parametrize("worker", [lazy_fixture(CELERY_WORKER)])
class test_celey_test_worker:
def test_app(self, worker: CeleryTestWorker, celery_setup_app: Celery):
assert worker.app is celery_setup_app
class test_celey_test_worker(BaseNodes):
@pytest.fixture
def node(self, celery_worker: CeleryTestWorker) -> CeleryTestNode:
return celery_worker

def test_version(self, worker: CeleryTestWorker):
assert worker.version == CeleryWorkerContainer.version()
def test_app(self, celery_worker: CeleryTestWorker, celery_setup_app: Celery):
assert celery_worker.app is celery_setup_app

def test_hostname(self, worker: CeleryTestWorker):
hostname = worker.hostname()
def test_version(self, celery_worker: CeleryTestWorker):
assert celery_worker.version == CeleryWorkerContainer.version()

def test_hostname(self, celery_worker: CeleryTestWorker):
hostname = celery_worker.hostname()
assert "@" in hostname
assert worker.worker_name in hostname.split("@")[0]
assert worker.container.id[:12] in hostname.split("@")[1]
assert celery_worker.worker_name in hostname.split("@")[0]
assert celery_worker.container.id[:12] in hostname.split("@")[1]

def test_wait_for_log(self, celery_worker: CeleryTestWorker):
log = f"{celery_worker.hostname()} v{celery_worker.version}"
celery_worker.wait_for_log(log, "test_celey_test_worker.test_wait_for_log")

def test_wait_for_log(self, worker: CeleryTestWorker):
log = f"{worker.hostname()} v{worker.version}"
worker.wait_for_log(log, "test_celey_test_worker.test_wait_for_log")
def test_assert_log_exists(self, celery_worker: CeleryTestWorker):
log = f"{celery_worker.hostname()} v{celery_worker.version}"
celery_worker.assert_log_exists(log, "test_celey_test_worker.test_assert_log_exists")

def test_assert_log_exists(self, worker: CeleryTestWorker):
log = f"{worker.hostname()} v{worker.version}"
worker.assert_log_exists(log, "test_celey_test_worker.test_assert_log_exists")

class test_celery_worker_cluster(BaseCluster):
@pytest.fixture
def cluster(self, celery_worker_cluster: CeleryWorkerCluster) -> CeleryTestCluster:
return celery_worker_cluster

@pytest.mark.parametrize("cluster", [lazy_fixture(CELERY_WORKER_CLUSTER)])
class test_celery_worker_cluster:
def test_app(self, cluster: CeleryWorkerCluster, celery_setup_app: Celery):
def test_app(self, celery_worker_cluster: CeleryWorkerCluster, celery_setup_app: Celery):
worker: CeleryTestWorker
for worker in cluster:
for worker in celery_worker_cluster:
assert worker.app is celery_setup_app

def test_config(self, cluster: CeleryWorkerCluster):
def test_config(self, celery_worker_cluster: CeleryWorkerCluster):
with pytest.raises(NotImplementedError):
cluster.config()
celery_worker_cluster.config()

def test_versions(self, cluster: CeleryWorkerCluster):
assert cluster.versions == {CeleryWorkerContainer.version()}
def test_versions(self, celery_worker_cluster: CeleryWorkerCluster):
assert celery_worker_cluster.versions == {CeleryWorkerContainer.version()}
18 changes: 10 additions & 8 deletions tests/integration/vendors/test_memcached.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_MEMCACHED_BACKEND
from pytest_celery import MemcachedContainer
from pytest_celery import MemcachedTestBackend
from tests.defaults import ALL_MEMCACHED_FIXTURES


@pytest.mark.parametrize("container", lazy_fixture(ALL_MEMCACHED_FIXTURES))
@pytest.fixture
def container(request):
return request.getfixturevalue(request.param)


@pytest.mark.parametrize("container", ALL_MEMCACHED_FIXTURES, indirect=["container"])
class test_memcached_container:
def test_client(self, container: MemcachedContainer):
assert container.client
Expand All @@ -26,10 +29,9 @@ def test_celeryconfig(self, container: MemcachedContainer):
assert container.prefix() in config["host_url"]


@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_MEMCACHED_BACKEND)])
class test_memcached_test_backend:
def test_config(self, backend: MemcachedTestBackend):
def test_config(self, celery_memcached_backend: MemcachedTestBackend):
expected_keys = {"url", "host_url", "hostname", "port"}
assert set(backend.config().keys()) == expected_keys
assert backend.container.prefix() in backend.config()["url"]
assert backend.container.prefix() in backend.config()["host_url"]
assert set(celery_memcached_backend.config().keys()) == expected_keys
assert celery_memcached_backend.container.prefix() in celery_memcached_backend.config()["url"]
assert celery_memcached_backend.container.prefix() in celery_memcached_backend.config()["host_url"]
18 changes: 10 additions & 8 deletions tests/integration/vendors/test_rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import pytest
from kombu import Connection
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_RABBITMQ_BROKER
from pytest_celery import RabbitMQContainer
from pytest_celery import RabbitMQTestBroker
from tests.defaults import ALL_RABBITMQ_FIXTURES


@pytest.mark.parametrize("container", lazy_fixture(ALL_RABBITMQ_FIXTURES))
@pytest.fixture
def container(request):
return request.getfixturevalue(request.param)


@pytest.mark.parametrize("container", ALL_RABBITMQ_FIXTURES, indirect=["container"])
class test_rabbitmq_container:
def test_client(self, container: RabbitMQContainer):
c: Connection = container.client
Expand All @@ -28,10 +31,9 @@ def test_celeryconfig(self, container: RabbitMQContainer):
assert container.prefix() in config["host_url"]


@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_RABBITMQ_BROKER)])
class test_rabbitmq_test_broker:
def test_config(self, broker: RabbitMQTestBroker):
def test_config(self, celery_rabbitmq_broker: RabbitMQTestBroker):
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
assert set(broker.config().keys()) == expected_keys
assert broker.container.prefix() in broker.config()["url"]
assert broker.container.prefix() in broker.config()["host_url"]
assert set(celery_rabbitmq_broker.config().keys()) == expected_keys
assert celery_rabbitmq_broker.container.prefix() in celery_rabbitmq_broker.config()["url"]
assert celery_rabbitmq_broker.container.prefix() in celery_rabbitmq_broker.config()["host_url"]
28 changes: 14 additions & 14 deletions tests/integration/vendors/test_redis.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from __future__ import annotations

import pytest
from pytest_lazyfixture import lazy_fixture

from pytest_celery import CELERY_REDIS_BACKEND
from pytest_celery import CELERY_REDIS_BROKER
from pytest_celery import RedisContainer
from pytest_celery import RedisTestBackend
from pytest_celery import RedisTestBroker
from tests.defaults import ALL_REDIS_FIXTURES


@pytest.mark.parametrize("container", lazy_fixture(ALL_REDIS_FIXTURES))
@pytest.fixture
def container(request):
return request.getfixturevalue(request.param)


@pytest.mark.parametrize("container", ALL_REDIS_FIXTURES, indirect=["container"])
class test_redis_container:
def test_client(self, container: RedisContainer):
assert container.client
Expand All @@ -28,19 +30,17 @@ def test_celeryconfig(self, container: RedisContainer):
assert container.prefix() in config["host_url"]


@pytest.mark.parametrize("backend", [lazy_fixture(CELERY_REDIS_BACKEND)])
class test_redis_test_backend:
def test_config(self, backend: RedisTestBackend):
def test_config(self, celery_redis_backend: RedisTestBackend):
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
assert set(backend.config().keys()) == expected_keys
assert backend.container.prefix() in backend.config()["url"]
assert backend.container.prefix() in backend.config()["host_url"]
assert set(celery_redis_backend.config().keys()) == expected_keys
assert celery_redis_backend.container.prefix() in celery_redis_backend.config()["url"]
assert celery_redis_backend.container.prefix() in celery_redis_backend.config()["host_url"]


@pytest.mark.parametrize("broker", [lazy_fixture(CELERY_REDIS_BROKER)])
class test_redis_test_broker:
def test_config(self, broker: RedisTestBroker):
def test_config(self, celery_redis_broker: RedisTestBroker):
expected_keys = {"url", "host_url", "hostname", "port", "vhost"}
assert set(broker.config().keys()) == expected_keys
assert broker.container.prefix() in broker.config()["url"]
assert broker.container.prefix() in broker.config()["host_url"]
assert set(celery_redis_broker.config().keys()) == expected_keys
assert celery_redis_broker.container.prefix() in celery_redis_broker.config()["url"]
assert celery_redis_broker.container.prefix() in celery_redis_broker.config()["host_url"]
Loading