diff --git a/libpathod/app.py b/libpathod/app.py index c1fb670ff..ebcf0369a 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -93,7 +93,8 @@ def _preview(is_request): spec = spec, section = "main", syntaxerror = None, - error = None + error = None, + pauses = None ) if not spec.strip(): args["error"] = "Can't parse an empty spec." @@ -113,7 +114,7 @@ def _preview(is_request): return render(template, **args) s = cStringIO.StringIO() - r.preview_safe() + args["pauses"] = r.preview_safe() if is_request: r.serve(s, check=app.config["pathod"].check_size, host="example.com") diff --git a/libpathod/rparse.py b/libpathod/rparse.py index ea12185be..1a6159503 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -533,9 +533,11 @@ class Message: 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"] + return pauses def effective_length(self, actions): """ diff --git a/libpathod/templates/request_preview.html b/libpathod/templates/request_preview.html index eaf78898c..40f7771e0 100644 --- a/libpathod/templates/request_preview.html +++ b/libpathod/templates/request_preview.html @@ -17,6 +17,10 @@
{{ output }}
+ {% if pauses %} +

Note: pauses are skipped when generating previews!

+ {% endif %} + {% endif %} {% include "request_previewform.html" %} {% endblock %} diff --git a/libpathod/templates/response_preview.html b/libpathod/templates/response_preview.html index 2e1abcf44..dd05e0217 100644 --- a/libpathod/templates/response_preview.html +++ b/libpathod/templates/response_preview.html @@ -17,6 +17,10 @@
{{ output }}
+ {% if pauses %} +

Note: pauses are skipped when generating previews!

+ {% endif %} + {% endif %} {% include "response_previewform.html" %} {% endblock %} diff --git a/test/test_rparse.py b/test/test_rparse.py index 57520176d..3cbec3351 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -510,7 +510,7 @@ class TestResponse: def test_render(self): r = rparse.parse_response({}, "400:p0,100:dr") assert r.actions[0][1] == "pause" - r.preview_safe() + assert len(r.preview_safe()) == 1 assert not r.actions[0][1] == "pause"