Skip to content

Commit

Permalink
Remove __str__ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Dec 30, 2020
1 parent a907e8b commit 041f138
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
12 changes: 0 additions & 12 deletions src/turbo_response/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def __init__(self, target, action):
self.action = action
self.target = target

def __str__(self):
return self.render()

def render(self, content=""):
return render_turbo_stream(
action=self.action, target=self.target, content=content
Expand Down Expand Up @@ -70,9 +67,6 @@ def __init__(self, template_name, context, *, action, target, **template_kwargs)
self.context = context
self.template_kwargs = template_kwargs

def __str__(self):
return self.render()

def render(self):
return render_turbo_stream_template(
self.template_name,
Expand All @@ -97,9 +91,6 @@ class TurboFrame:
def __init__(self, dom_id):
self.dom_id = dom_id

def __str__(self):
return self.render()

def render(self, content=""):
return render_turbo_frame(dom_id=self.dom_id, content=content)

Expand All @@ -121,9 +112,6 @@ def __init__(self, template_name, context, *, dom_id, **template_kwargs):
self.template_kwargs = template_kwargs
self.dom_id = dom_id

def __str__(self):
return self.render()

def render(self):
return render_turbo_frame_template(
self.template_name, self.context, dom_id=self.dom_id, **self.template_kwargs
Expand Down
15 changes: 2 additions & 13 deletions src/turbo_response/tests/test_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ def test_render(self):
s = TurboFrame("my-form").render("OK")
assert s == '<turbo-frame id="my-form">OK</turbo-frame>'

def test_str(self):
s = str(TurboFrame("my-form"))
assert s == '<turbo-frame id="my-form"></turbo-frame>'

def test_template(self):
s = str(TurboFrame("my-form").template("simple.html", {}))
s = TurboFrame("my-form").template("simple.html", {}).render()
assert "my content" in s
assert '<turbo-frame id="my-form">' in s

Expand Down Expand Up @@ -40,15 +36,8 @@ def test_render(self):
== '<turbo-stream action="append" target="my-form"><template>OK</template></turbo-stream>'
)

def test_str(self):
s = str(TurboStream("my-form").remove)
assert (
s
== '<turbo-stream action="remove" target="my-form"><template></template></turbo-stream>'
)

def test_template(self):
s = str(TurboStream("my-form").append.template("simple.html", {}))
s = TurboStream("my-form").append.template("simple.html", {}).render()
assert "my content" in s
assert '<turbo-stream action="append" target="my-form">' in s

Expand Down

0 comments on commit 041f138

Please sign in to comment.