Skip to content

Commit

Permalink
Fix utils to not require TENANT_USE_ASGIREF to be defined in the ho…
Browse files Browse the repository at this point in the history
…st django project (#206)

* Fix if statement

* try fix tests
  • Loading branch information
ekampf authored Dec 18, 2023
1 parent d119cc5 commit 44b4e86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions django_multitenant/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_tenant_persists_from_async_task_to_thread(self):
account = projects[0].account

with self.settings(TENANT_USE_ASGIREF=True):
importlib.reload(sys.modules["django_multitenant.settings"])
importlib.reload(sys.modules["django_multitenant.utils"])

# Set the tenant in task
Expand All @@ -66,6 +67,7 @@ def test_tenant_persists_from_async_task_to_thread(self):
unset_current_tenant()

with self.settings(TENANT_USE_ASGIREF=False):
importlib.reload(sys.modules["django_multitenant.settings"])
importlib.reload(sys.modules["django_multitenant.utils"])

# Set the tenant in task
Expand Down
4 changes: 2 additions & 2 deletions django_multitenant/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import inspect

from django.apps import apps
from django.conf import settings
from .settings import TENANT_USE_ASGIREF


if settings.TENANT_USE_ASGIREF:
if TENANT_USE_ASGIREF:
# asgiref must be installed, its included with Django >= 3.0
from asgiref.local import Local as local
else:
Expand Down

0 comments on commit 44b4e86

Please sign in to comment.