mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
parent
84db2b7314
commit
0f278f3c25
2 changed files with 17 additions and 2 deletions
|
@ -4,7 +4,7 @@ from typing import List
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class ContextBehavior(Enum):
|
class ContextBehavior(str, Enum):
|
||||||
GLOBAL = "global"
|
GLOBAL = "global"
|
||||||
ISOLATED = "isolated"
|
ISOLATED = "isolated"
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,19 @@ class ValidateWrongContextBehaviorValueTestCase(SimpleTestCase):
|
||||||
from django_components.app_settings import app_settings
|
from django_components.app_settings import app_settings
|
||||||
|
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
app_settings.CONTEXT_BEHAVIOR.value
|
app_settings.CONTEXT_BEHAVIOR
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateCorrectContextBehaviorValueTestCase(SimpleTestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
settings.COMPONENTS["context_behavior"] = "isolated"
|
||||||
|
return super().setUp()
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
del settings.COMPONENTS["context_behavior"]
|
||||||
|
return super().tearDown()
|
||||||
|
|
||||||
|
def test_valid_context_behavior(self):
|
||||||
|
from django_components.app_settings import app_settings
|
||||||
|
|
||||||
|
self.assertEqual(app_settings.CONTEXT_BEHAVIOR, "isolated")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue