File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,21 @@ def ready(self) -> bool:
7474
7575 def config (self , * args : tuple , ** kwargs : dict ) -> dict :
7676 """Compile the configurations required for Celery from this node."""
77- return self .container .celeryconfig
77+ config = self .container .celeryconfig
78+
79+ if not args and not kwargs :
80+ return config
81+
82+ for key , value in kwargs .items ():
83+ config [key ] = value
84+
85+ if key == "vhost" :
86+ vhost = str (value )
87+ config ["url" ] = f"{ config ['url' ][:- 1 ].rstrip ('/' )} /{ vhost } "
88+ config ["host_url" ] = f"{ config ['host_url' ][:- 1 ].rstrip ('/' )} /{ vhost } "
89+ config [key ] = vhost
90+
91+ return config
7892
7993 def logs (self ) -> str :
8094 """Get the logs of the underlying container."""
Original file line number Diff line number Diff line change @@ -56,6 +56,17 @@ def test_ready(self, node: CeleryTestNode):
5656 def test_config (self , node : CeleryTestNode ):
5757 assert node .config ()
5858
59+ def test_config_kwarg_vhost (self , node : CeleryTestNode ):
60+ vhost = "/test_vhost"
61+ config = node .config ()
62+ assert "vhost" not in config
63+ assert config ["url" ].endswith (vhost ) is False
64+ assert config ["host_url" ].endswith (vhost ) is False
65+ config = node .config (vhost = vhost [1 :])
66+ assert config ["vhost" ] == vhost [1 :]
67+ assert config ["url" ].endswith (vhost )
68+ assert config ["host_url" ].endswith (vhost )
69+
5970 def test_logs (self , node : CeleryTestNode ):
6071 assert node .logs ()
6172
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ def mocked_container(spec: type) -> Mock:
2020 mocked_container = Mock (spec = spec )
2121 mocked_container .id = "mocked_test_container_id"
2222 mocked_container .celeryconfig = {
23- "url" : "mocked_url" ,
24- "host_url" : "mocked_host_url" ,
23+ "url" : "mocked_url/ " ,
24+ "host_url" : "mocked_host_url/ " ,
2525 }
2626 return mocked_container
2727
You can’t perform that action at this time.
0 commit comments