diff --git a/src/pytest_celery/api/backend.py b/src/pytest_celery/api/backend.py index 328f63f5..bcbd8574 100644 --- a/src/pytest_celery/api/backend.py +++ b/src/pytest_celery/api/backend.py @@ -17,7 +17,7 @@ class CeleryTestBackend(CeleryTestNode): def default_config(cls) -> dict: return { "url": DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"], - "local_url": DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"], + "host_url": DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"], } def restart(self, reload_container: bool = True, force: bool = False) -> None: @@ -26,7 +26,7 @@ def restart(self, reload_container: bool = True, force: bool = False) -> None: super().restart(reload_container, force) if self.app: self.app.conf.update( - result_backend=self.config()["local_url"], + result_backend=self.config()["host_url"], ) @@ -42,5 +42,5 @@ class CeleryBackendCluster(CeleryTestCluster): def default_config(cls) -> dict: return { "urls": [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]], - "local_urls": [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]], + "host_urls": [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]], } diff --git a/src/pytest_celery/api/base.py b/src/pytest_celery/api/base.py index 13da2fac..542e954e 100644 --- a/src/pytest_celery/api/base.py +++ b/src/pytest_celery/api/base.py @@ -255,7 +255,7 @@ def config(self, *args: tuple, **kwargs: dict) -> dict: config = [node.container.celeryconfig for node in self] return { "urls": [c["url"] for c in config], - "local_urls": [c["local_url"] for c in config], + "host_urls": [c["host_url"] for c in config], } def teardown(self) -> None: diff --git a/src/pytest_celery/api/broker.py b/src/pytest_celery/api/broker.py index ea1dbc0b..66150598 100644 --- a/src/pytest_celery/api/broker.py +++ b/src/pytest_celery/api/broker.py @@ -17,7 +17,7 @@ class CeleryTestBroker(CeleryTestNode): def default_config(cls) -> dict: return { "url": DEFAULT_WORKER_ENV["CELERY_BROKER_URL"], - "local_url": DEFAULT_WORKER_ENV["CELERY_BROKER_URL"], + "host_url": DEFAULT_WORKER_ENV["CELERY_BROKER_URL"], } def restart(self, reload_container: bool = True, force: bool = False) -> None: @@ -26,7 +26,7 @@ def restart(self, reload_container: bool = True, force: bool = False) -> None: super().restart(reload_container, force) if self.app: self.app.conf.update( - broker_url=self.config()["local_url"], + broker_url=self.config()["host_url"], ) @@ -42,5 +42,5 @@ class CeleryBrokerCluster(CeleryTestCluster): def default_config(cls) -> dict: return { "urls": [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]], - "local_urls": [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]], + "host_urls": [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]], } diff --git a/src/pytest_celery/api/setup.py b/src/pytest_celery/api/setup.py index 69730bc4..9a99707c 100644 --- a/src/pytest_celery/api/setup.py +++ b/src/pytest_celery/api/setup.py @@ -111,9 +111,9 @@ def config(cls, celery_worker_cluster_config: dict) -> dict: celery_backend_cluster_config: dict = celery_worker_cluster_config.get("celery_backend_cluster_config", {}) config = {} if celery_broker_cluster_config: - config["broker_url"] = ";".join(celery_broker_cluster_config["local_urls"]) + config["broker_url"] = ";".join(celery_broker_cluster_config["host_urls"]) if celery_backend_cluster_config: - config["result_backend"] = ";".join(celery_backend_cluster_config["local_urls"]) + config["result_backend"] = ";".join(celery_backend_cluster_config["host_urls"]) return config @classmethod diff --git a/src/pytest_celery/vendors/memcached/container.py b/src/pytest_celery/vendors/memcached/container.py index 16eb0dff..d0c3e2d8 100644 --- a/src/pytest_celery/vendors/memcached/container.py +++ b/src/pytest_celery/vendors/memcached/container.py @@ -13,7 +13,7 @@ class MemcachedContainer(CeleryTestContainer): @property def client(self) -> memcache.Client: conf = self.celeryconfig - servers = [f"{conf['local_url'][:-1].split('://')[-1]}"] + servers = [f"{conf['host_url'][:-1].split('://')[-1]}"] client = memcache.Client(servers) return client @@ -21,7 +21,7 @@ def client(self) -> memcache.Client: def celeryconfig(self) -> dict: return { "url": self.url, - "local_url": self.local_url, + "host_url": self.host_url, "hostname": self.hostname, "port": self.port, } @@ -31,7 +31,7 @@ def url(self) -> str: return f"{self.prefix()}{self.hostname}/" @property - def local_url(self) -> str: + def host_url(self) -> str: return f"{self.prefix()}localhost:{self.port}/" @property diff --git a/src/pytest_celery/vendors/rabbitmq/container.py b/src/pytest_celery/vendors/rabbitmq/container.py index 0101c7da..5b2dfc02 100644 --- a/src/pytest_celery/vendors/rabbitmq/container.py +++ b/src/pytest_celery/vendors/rabbitmq/container.py @@ -13,7 +13,7 @@ class RabbitMQContainer(CeleryTestContainer): @property def client(self) -> Connection: client = Connection( - self.celeryconfig["local_url"], + self.celeryconfig["host_url"], port=self.celeryconfig["port"], ) return client @@ -22,7 +22,7 @@ def client(self) -> Connection: def celeryconfig(self) -> dict: return { "url": self.url, - "local_url": self.local_url, + "host_url": self.host_url, "hostname": self.hostname, "port": self.port, "vhost": self.vhost, @@ -33,7 +33,7 @@ def url(self) -> str: return f"{self.prefix()}{self.hostname}/{self.vhost}" @property - def local_url(self) -> str: + def host_url(self) -> str: return f"{self.prefix()}localhost:{self.port}/{self.vhost}" @property diff --git a/src/pytest_celery/vendors/redis/container.py b/src/pytest_celery/vendors/redis/container.py index bdeab323..bc0588bc 100644 --- a/src/pytest_celery/vendors/redis/container.py +++ b/src/pytest_celery/vendors/redis/container.py @@ -13,7 +13,7 @@ class RedisContainer(CeleryTestContainer): @property def client(self) -> Redis | None: client = Redis.from_url( - self.celeryconfig["local_url"], + self.celeryconfig["host_url"], decode_responses=True, ) return client @@ -22,7 +22,7 @@ def client(self) -> Redis | None: def celeryconfig(self) -> dict: return { "url": self.url, - "local_url": self.local_url, + "host_url": self.host_url, "hostname": self.hostname, "port": self.port, "vhost": self.vhost, @@ -37,7 +37,7 @@ def url(self) -> str: return f"{self.prefix()}{self.hostname}/{self.vhost}" @property - def local_url(self) -> str: + def host_url(self) -> str: return f"{self.prefix()}localhost:{self.port}/{self.vhost}" @property diff --git a/tests/integration/api/custom_setup/test_custom_setup.py b/tests/integration/api/custom_setup/test_custom_setup.py index 225e8f07..a7cf6e7c 100644 --- a/tests/integration/api/custom_setup/test_custom_setup.py +++ b/tests/integration/api/custom_setup/test_custom_setup.py @@ -16,8 +16,7 @@ def test_ready(self, celery_setup: CeleryTestSetup): def test_worker_is_connected_to_backend(self, celery_setup: CeleryTestSetup): backend_urls = [ - backend.container.celeryconfig["local_url"].replace("cache+", "") - for backend in celery_setup.backend_cluster + backend.container.celeryconfig["host_url"].replace("cache+", "") for backend in celery_setup.backend_cluster ] worker: CeleryTestWorker for worker in celery_setup.worker_cluster: @@ -25,7 +24,7 @@ def test_worker_is_connected_to_backend(self, celery_setup: CeleryTestSetup): assert app.backend.as_uri() in backend_urls def test_worker_is_connected_to_broker(self, celery_setup: CeleryTestSetup): - broker_urls = [broker.container.celeryconfig["local_url"] for broker in celery_setup.broker_cluster] + broker_urls = [broker.container.celeryconfig["host_url"] for broker in celery_setup.broker_cluster] worker: CeleryTestWorker for worker in celery_setup.worker_cluster: app: Celery = worker.app diff --git a/tests/integration/api/test_backend.py b/tests/integration/api/test_backend.py index da05d115..a15d6dfc 100644 --- a/tests/integration/api/test_backend.py +++ b/tests/integration/api/test_backend.py @@ -23,5 +23,5 @@ def test_app(self, cluster: CeleryBackendCluster): assert backend.app is None def test_config(self, cluster: CeleryBackendCluster): - expected_keys = {"urls", "local_urls"} + expected_keys = {"urls", "host_urls"} assert set(cluster.config().keys()) == expected_keys diff --git a/tests/integration/api/test_broker.py b/tests/integration/api/test_broker.py index a4d05373..850f5586 100644 --- a/tests/integration/api/test_broker.py +++ b/tests/integration/api/test_broker.py @@ -23,5 +23,5 @@ def test_app(self, cluster: CeleryBrokerCluster): assert broker.app is None def test_config(self, cluster: CeleryBrokerCluster): - expected_keys = {"urls", "local_urls"} + expected_keys = {"urls", "host_urls"} assert set(cluster.config().keys()) == expected_keys diff --git a/tests/integration/api/test_setup.py b/tests/integration/api/test_setup.py index 69e0c33c..26ed7b0d 100644 --- a/tests/integration/api/test_setup.py +++ b/tests/integration/api/test_setup.py @@ -28,8 +28,7 @@ def test_ready(self, celery_setup: CeleryTestSetup, confirmation: dict): def test_worker_is_connected_to_backend(self, celery_setup: CeleryTestSetup): backend_urls = [ - backend.container.celeryconfig["local_url"].replace("cache+", "") - for backend in celery_setup.backend_cluster + backend.container.celeryconfig["host_url"].replace("cache+", "") for backend in celery_setup.backend_cluster ] worker: CeleryTestWorker for worker in celery_setup.worker_cluster: @@ -37,7 +36,7 @@ def test_worker_is_connected_to_backend(self, celery_setup: CeleryTestSetup): assert app.backend.as_uri() in backend_urls def test_worker_is_connected_to_broker(self, celery_setup: CeleryTestSetup): - broker_urls = [broker.container.celeryconfig["local_url"] for broker in celery_setup.broker_cluster] + broker_urls = [broker.container.celeryconfig["host_url"] for broker in celery_setup.broker_cluster] worker: CeleryTestWorker for worker in celery_setup.worker_cluster: app: Celery = worker.app diff --git a/tests/integration/vendors/test_memcached.py b/tests/integration/vendors/test_memcached.py index 3556a669..42840c8d 100644 --- a/tests/integration/vendors/test_memcached.py +++ b/tests/integration/vendors/test_memcached.py @@ -19,17 +19,17 @@ def test_client(self, container: MemcachedContainer): assert container.client.delete("ready") def test_celeryconfig(self, container: MemcachedContainer): - expected_keys = {"url", "local_url", "hostname", "port"} + expected_keys = {"url", "host_url", "hostname", "port"} config = container.celeryconfig assert set(config.keys()) == expected_keys assert container.prefix() in config["url"] - assert container.prefix() in config["local_url"] + 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): - expected_keys = {"url", "local_url", "hostname", "port"} + 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()["local_url"] + assert backend.container.prefix() in backend.config()["host_url"] diff --git a/tests/integration/vendors/test_rabbitmq.py b/tests/integration/vendors/test_rabbitmq.py index fd9dbbba..0673afc7 100644 --- a/tests/integration/vendors/test_rabbitmq.py +++ b/tests/integration/vendors/test_rabbitmq.py @@ -21,17 +21,17 @@ def test_client(self, container: RabbitMQContainer): c.release() def test_celeryconfig(self, container: RabbitMQContainer): - expected_keys = {"url", "local_url", "hostname", "port", "vhost"} + expected_keys = {"url", "host_url", "hostname", "port", "vhost"} config = container.celeryconfig assert set(config.keys()) == expected_keys assert container.prefix() in config["url"] - assert container.prefix() in config["local_url"] + 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): - expected_keys = {"url", "local_url", "hostname", "port", "vhost"} + 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()["local_url"] + assert broker.container.prefix() in broker.config()["host_url"] diff --git a/tests/integration/vendors/test_redis.py b/tests/integration/vendors/test_redis.py index 485375fa..cf13a57c 100644 --- a/tests/integration/vendors/test_redis.py +++ b/tests/integration/vendors/test_redis.py @@ -21,26 +21,26 @@ def test_client(self, container: RedisContainer): assert container.client.delete("ready") def test_celeryconfig(self, container: RedisContainer): - expected_keys = {"url", "local_url", "hostname", "port", "vhost"} + expected_keys = {"url", "host_url", "hostname", "port", "vhost"} config = container.celeryconfig assert set(config.keys()) == expected_keys assert container.prefix() in config["url"] - assert container.prefix() in config["local_url"] + 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): - expected_keys = {"url", "local_url", "hostname", "port", "vhost"} + 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()["local_url"] + assert backend.container.prefix() in backend.config()["host_url"] @pytest.mark.parametrize("broker", [lazy_fixture(CELERY_REDIS_BROKER)]) class test_redis_test_broker: def test_config(self, broker: RedisTestBroker): - expected_keys = {"url", "local_url", "hostname", "port", "vhost"} + 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()["local_url"] + assert broker.container.prefix() in broker.config()["host_url"] diff --git a/tests/unit/api/test_backend.py b/tests/unit/api/test_backend.py index 22b7fec6..edc48ce5 100644 --- a/tests/unit/api/test_backend.py +++ b/tests/unit/api/test_backend.py @@ -15,7 +15,7 @@ class test_celey_test_backend: def test_default_config_format(self, backend: CeleryTestBackend): assert backend.default_config()["url"] == DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"] - assert backend.default_config()["local_url"] == DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"] + assert backend.default_config()["host_url"] == DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"] def test_restart_no_app(self, backend: CeleryTestBackend): assert backend.app is None @@ -32,7 +32,7 @@ def test_restart_with_app(self, backend: CeleryTestBackend, celery_setup_app: Ce class test_celery_backend_cluster: def test_default_config_format(self, cluster: CeleryBackendCluster): assert cluster.default_config()["urls"] == [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]] - assert cluster.default_config()["local_urls"] == [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]] + assert cluster.default_config()["host_urls"] == [DEFAULT_WORKER_ENV["CELERY_RESULT_BACKEND"]] class test_disabling_cluster: @pytest.fixture diff --git a/tests/unit/api/test_broker.py b/tests/unit/api/test_broker.py index ffdf0388..4cb9b93b 100644 --- a/tests/unit/api/test_broker.py +++ b/tests/unit/api/test_broker.py @@ -15,7 +15,7 @@ class test_celey_test_broker: def test_default_config_format(self, broker: CeleryTestBroker): assert broker.default_config()["url"] == DEFAULT_WORKER_ENV["CELERY_BROKER_URL"] - assert broker.default_config()["local_url"] == DEFAULT_WORKER_ENV["CELERY_BROKER_URL"] + assert broker.default_config()["host_url"] == DEFAULT_WORKER_ENV["CELERY_BROKER_URL"] def test_restart_no_app(self, broker: CeleryTestBroker): assert broker.app is None @@ -32,7 +32,7 @@ def test_restart_with_app(self, broker: CeleryTestBroker, celery_setup_app: Cele class test_celery_broker_cluster: def test_default_config_format(self, cluster: CeleryBrokerCluster): assert cluster.default_config()["urls"] == [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]] - assert cluster.default_config()["local_urls"] == [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]] + assert cluster.default_config()["host_urls"] == [DEFAULT_WORKER_ENV["CELERY_BROKER_URL"]] class test_disabling_cluster: @pytest.fixture diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index bcf3aae6..bfbde243 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -21,7 +21,7 @@ def mocked_container(spec: type) -> Mock: mocked_container.id = "mocked_test_container_id" mocked_container.celeryconfig = { "url": "mocked_url", - "local_url": "mocked_local_url", + "host_url": "mocked_host_url", } return mocked_container