Note that pauses are skipped during previews.

This commit is contained in:
Aldo Cortesi 2012-07-25 12:49:22 +12:00
parent 24f69419df
commit eb43291b3c
5 changed files with 15 additions and 4 deletions

View File

@ -93,7 +93,8 @@ def _preview(is_request):
spec = spec, spec = spec,
section = "main", section = "main",
syntaxerror = None, syntaxerror = None,
error = None error = None,
pauses = None
) )
if not spec.strip(): if not spec.strip():
args["error"] = "Can't parse an empty spec." args["error"] = "Can't parse an empty spec."
@ -113,7 +114,7 @@ def _preview(is_request):
return render(template, **args) return render(template, **args)
s = cStringIO.StringIO() s = cStringIO.StringIO()
r.preview_safe() args["pauses"] = r.preview_safe()
if is_request: if is_request:
r.serve(s, check=app.config["pathod"].check_size, host="example.com") r.serve(s, check=app.config["pathod"].check_size, host="example.com")

View File

@ -533,9 +533,11 @@ class Message:
def preview_safe(self): def preview_safe(self):
""" """
Modify this message to be safe for previews. Modify this message to be safe for previews. Returns a list of elided actions.
""" """
pauses = [i for i in self.actions if i[1] == "pause"]
self.actions = [i for i in self.actions if i[1] != "pause"] self.actions = [i for i in self.actions if i[1] != "pause"]
return pauses
def effective_length(self, actions): def effective_length(self, actions):
""" """

View File

@ -17,6 +17,10 @@
<pre>{{ output }}</pre> <pre>{{ output }}</pre>
{% if pauses %}
<p>Note: pauses are skipped when generating previews!</p>
{% endif %}
{% endif %} {% endif %}
{% include "request_previewform.html" %} {% include "request_previewform.html" %}
{% endblock %} {% endblock %}

View File

@ -17,6 +17,10 @@
<pre>{{ output }}</pre> <pre>{{ output }}</pre>
{% if pauses %}
<p>Note: pauses are skipped when generating previews!</p>
{% endif %}
{% endif %} {% endif %}
{% include "response_previewform.html" %} {% include "response_previewform.html" %}
{% endblock %} {% endblock %}

View File

@ -510,7 +510,7 @@ class TestResponse:
def test_render(self): def test_render(self):
r = rparse.parse_response({}, "400:p0,100:dr") r = rparse.parse_response({}, "400:p0,100:dr")
assert r.actions[0][1] == "pause" assert r.actions[0][1] == "pause"
r.preview_safe() assert len(r.preview_safe()) == 1
assert not r.actions[0][1] == "pause" assert not r.actions[0][1] == "pause"