Skip to content

Commit

Permalink
Hotfix: Override test node config using super().config(kwargs)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nusnus committed Mar 17, 2024
1 parent ad766c5 commit 471018b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/vhost/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def celery_broker_cluster(redis_broker: RedisTestBroker) -> CeleryBrokerCluster:

class MyRedisTestBackend(RedisTestBackend):
def config(self, *args: tuple, **kwargs: dict) -> dict:
return super().config(vhost=1, *args, **kwargs)
return super().config(vhost="1", *args, **kwargs)


@pytest.fixture
Expand Down
14 changes: 13 additions & 1 deletion src/pytest_celery/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,19 @@ def ready(self) -> bool:

def config(self, *args: tuple, **kwargs: dict) -> dict:
"""Compile the configurations required for Celery from this node."""
return self.container.celeryconfig
config = self.container.celeryconfig

if not args and not kwargs:
return config

for key, value in kwargs.items():
if key == "vhost":
config["url"] = f"{self.container.prefix()}{self.container.hostname}/{value}"
config["host_url"] = f"{self.container.prefix()}localhost:{self.container.port}/{value}"

Check warning on line 85 in src/pytest_celery/api/base.py

View check run for this annotation

Codecov / codecov/patch

src/pytest_celery/api/base.py#L84-L85

Added lines #L84 - L85 were not covered by tests

config[key] = value

Check warning on line 87 in src/pytest_celery/api/base.py

View check run for this annotation

Codecov / codecov/patch

src/pytest_celery/api/base.py#L87

Added line #L87 was not covered by tests

return config

Check warning on line 89 in src/pytest_celery/api/base.py

View check run for this annotation

Codecov / codecov/patch

src/pytest_celery/api/base.py#L89

Added line #L89 was not covered by tests

def logs(self) -> str:
"""Get the logs of the underlying container."""
Expand Down

0 comments on commit 471018b

Please sign in to comment.