aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpathod/app.py5
-rw-r--r--libpathod/rparse.py4
-rw-r--r--libpathod/templates/request_preview.html4
-rw-r--r--libpathod/templates/response_preview.html4
-rw-r--r--test/test_rparse.py2
5 files changed, 15 insertions, 4 deletions
diff --git a/libpathod/app.py b/libpathod/app.py
index c1fb670f..ebcf0369 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 ea12185b..1a615950 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 eaf78898..40f7771e 100644
--- a/libpathod/templates/request_preview.html
+++ b/libpathod/templates/request_preview.html
@@ -17,6 +17,10 @@
<pre>{{ output }}</pre>
+ {% if pauses %}
+ <p>Note: pauses are skipped when generating previews!</p>
+ {% endif %}
+
{% endif %}
{% include "request_previewform.html" %}
{% endblock %}
diff --git a/libpathod/templates/response_preview.html b/libpathod/templates/response_preview.html
index 2e1abcf4..dd05e021 100644
--- a/libpathod/templates/response_preview.html
+++ b/libpathod/templates/response_preview.html
@@ -17,6 +17,10 @@
<pre>{{ output }}</pre>
+ {% if pauses %}
+ <p>Note: pauses are skipped when generating previews!</p>
+ {% endif %}
+
{% endif %}
{% include "response_previewform.html" %}
{% endblock %}
diff --git a/test/test_rparse.py b/test/test_rparse.py
index 57520176..3cbec335 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"