mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 06:18:17 +00:00
refactor: add test for response_class
This commit is contained in:
parent
a5a0c74d31
commit
40f4476993
1 changed files with 18 additions and 0 deletions
|
@ -335,6 +335,24 @@ class ComponentRenderTest(BaseTestCase):
|
|||
""",
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
def test_render_to_response_change_response_class(self):
|
||||
class MyResponse:
|
||||
def __init__(self, content: str) -> None:
|
||||
self.content = bytes(content, "utf-8")
|
||||
|
||||
class SimpleComponent(component.Component):
|
||||
response_class = MyResponse
|
||||
template: types.django_html = "HELLO"
|
||||
|
||||
rendered = SimpleComponent.render_to_response()
|
||||
self.assertIsInstance(rendered, MyResponse)
|
||||
|
||||
self.assertHTMLEqual(
|
||||
rendered.content.decode(),
|
||||
"HELLO",
|
||||
)
|
||||
|
||||
@parametrize_context_behavior([("django", False), ("isolated", True)])
|
||||
def test_render_slot_as_func(self, context_behavior_data):
|
||||
is_isolated = context_behavior_data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue