Skip to content
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
2 changes: 2 additions & 0 deletions eox_tenant/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def tenant_context_addition(sender, body, headers, *args, **kwargs): # pylint:

get_host_func = AsyncTaskHandler().get_host_from_task(sender)
headers['eox_tenant_sender'] = get_host_func(body)
body[1]['eox_tenant_sender'] = get_host_func(body) # body = (args, kwargs, Mapping embed)


def start_async_lms_tenant(sender, *args, **kwargs): # pylint: disable=unused-argument
Expand Down Expand Up @@ -262,6 +263,7 @@ def _start_async_tenant(sender, config_key):
context = sender.request
headers = context.get('headers') or {}
http_host = headers.get('eox_tenant_sender')
http_host = context.get('kwargs', {}).pop('eox_tenant_sender', http_host)

if not http_host: # Reset settings in case of no tenant.
LOG.warning("Could not find the host information for eox_tenant.signals. ")
Expand Down
13 changes: 7 additions & 6 deletions eox_tenant/test/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ class CeleryReceiverCLISyncTests(TestCase):

def setUp(self):
""" setup """
self.body = {
'kwargs': {},
}
args = []
kwargs = {} # This is the default value for kwargs
self.body = (args, kwargs)
for number in range(3):
Site.objects.create(
domain=f"tenant{number}.com",
Expand Down Expand Up @@ -354,9 +354,10 @@ def test_sync_process_with_tenant(self):
When the task is called from a sync proccess it is used the value of the 'host' key in the request dict.
"""
headers = {}
body = {
'kwargs': {},
}
args = []
kwargs = {}
body = (args, kwargs)

with self.settings(EDNX_TENANT_DOMAIN="some.tenant.com"):
tenant_context_addition("some.task", headers=headers, body=body)

Expand Down