aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/templates
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-30 17:29:36 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-30 17:29:36 +1200
commite52a37ffa962f662cfcab8056c8af5b0ac9f416b (patch)
treea7d9f4edf1080422edd19f1360298e914628e675 /libpathod/templates
parente26aac1d3c6e4ca9f09cffa9d61d5a632dc35f14 (diff)
downloadmitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.tar.gz
mitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.tar.bz2
mitmproxy-e52a37ffa962f662cfcab8056c8af5b0ac9f416b.zip
Cleanup of libpathod.test, test example for front page.
Diffstat (limited to 'libpathod/templates')
-rw-r--r--libpathod/templates/docs_lang.html11
-rw-r--r--libpathod/templates/examples_test.html18
-rw-r--r--libpathod/templates/index.html2
-rw-r--r--libpathod/templates/response_previewform.html4
4 files changed, 27 insertions, 8 deletions
diff --git a/libpathod/templates/docs_lang.html b/libpathod/templates/docs_lang.html
index 46f5f401..ebed7388 100644
--- a/libpathod/templates/docs_lang.html
+++ b/libpathod/templates/docs_lang.html
@@ -31,8 +31,8 @@
<tr>
<td> b<a href="#valuespec">VALUE</a> </td>
<td>
- Set the body. When the body is set, pathod will
- automatically set the appropriate Content-Length header.
+ Set the body. The appropriate Content-Length header is
+ added automatically unless the "r" flag is set.
</td>
</tr>
@@ -104,8 +104,8 @@
<tr>
<td> b<a href="#valuespec">VALUE</a> </td>
<td>
- Set the body. When the body is set, pathod will
- automatically set the appropriate Content-Length header.
+ Set the body. The appropriate Content-Length header is
+ added automatically unless the "r" flag is set.
</td>
</tr>
@@ -143,8 +143,7 @@
<td> r </td>
<td>
Set the "raw" flag on this response. Pathod will not
- calculate a Content-Length header if a body is set, or add
- a Date header to the response.
+ calculate a Content-Length header if a body is set.
</td>
</tr>
</tbody>
diff --git a/libpathod/templates/examples_test.html b/libpathod/templates/examples_test.html
new file mode 100644
index 00000000..57d39534
--- /dev/null
+++ b/libpathod/templates/examples_test.html
@@ -0,0 +1,18 @@
+<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
+<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">test</span>
+
+<span class="k">class</span> <span class="nc">Test</span><span class="p">:</span>
+ <span class="k">def</span> <span class="nf">setUp</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span> <span class="o">=</span> <span class="n">test</span><span class="o">.</span><span class="n">Daemon</span><span class="p">()</span>
+
+ <span class="k">def</span> <span class="nf">tearDown</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span>
+
+ <span class="k">def</span> <span class="nf">test_simple</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+ <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">p</span><span class="p">(</span><span class="s">&quot;200:b@100&quot;</span><span class="p">)</span>
+ <span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
+ <span class="k">assert</span> <span class="n">r</span><span class="o">.</span><span class="n">status_code</span> <span class="o">==</span> <span class="mi">200</span>
+ <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">content</span><span class="p">)</span> <span class="o">==</span> <span class="mi">100</span>
+ <span class="n">log</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">daemon</span><span class="o">.</span><span class="n">last_log</span><span class="p">()</span>
+ <span class="k">assert</span> <span class="n">log</span><span class="p">[</span><span class="s">&quot;request&quot;</span><span class="p">][</span><span class="s">&quot;method&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&quot;GET&quot;</span>
+</pre></div>
diff --git a/libpathod/templates/index.html b/libpathod/templates/index.html
index 42c8c413..c31d4414 100644
--- a/libpathod/templates/index.html
+++ b/libpathod/templates/index.html
@@ -72,6 +72,8 @@
<p>Using pathod and pathoc in your unit tests.</p>
+ {% include "examples_test.html" %}
+
</div>
</div>
</div>
diff --git a/libpathod/templates/response_previewform.html b/libpathod/templates/response_previewform.html
index 19e28d08..6c2efded 100644
--- a/libpathod/templates/response_previewform.html
+++ b/libpathod/templates/response_previewform.html
@@ -1,6 +1,6 @@
<form style="margin-bottom: 0" class="form-inline" method="GET" action="/response_preview">
<input
- style="width: 20em"
+ style="width: 18em"
id="spec"
name="spec"
class="input-medium search-query"
@@ -9,7 +9,7 @@
>
<input type="submit" class="btn" value="preview">
{% if not nocraft %}
- <a href="#" id="submitspec" class="btn">go to</a>
+ <a href="#" id="submitspec" class="btn">go</a>
{% endif %}
</form>