aboutsummaryrefslogtreecommitdiffstats
path: root/.sources
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-30 20:58:59 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-30 20:58:59 +1200
commitfde65270afb3855057a86b40c5996c86f58fe97b (patch)
treedad83bd28cdfa36178560b7bcb7832d92c7a14c8 /.sources
parente52a37ffa962f662cfcab8056c8af5b0ac9f416b (diff)
downloadmitmproxy-fde65270afb3855057a86b40c5996c86f58fe97b.tar.gz
mitmproxy-fde65270afb3855057a86b40c5996c86f58fe97b.tar.bz2
mitmproxy-fde65270afb3855057a86b40c5996c86f58fe97b.zip
Testing examples and docs.
Diffstat (limited to '.sources')
-rw-r--r--.sources/examples_context.py23
-rw-r--r--.sources/examples_setup.py28
-rw-r--r--.sources/examples_setupall.py37
-rw-r--r--.sources/examples_test.py17
-rwxr-xr-x.sources/make4
5 files changed, 91 insertions, 18 deletions
diff --git a/.sources/examples_context.py b/.sources/examples_context.py
new file mode 100644
index 00000000..80278e76
--- /dev/null
+++ b/.sources/examples_context.py
@@ -0,0 +1,23 @@
+import requests
+from libpathod import test
+
+class Test:
+ """
+ Testing the requests module with
+ a pathod context manager.
+ """
+ def test_simple(self):
+ # Start pathod in a separate thread
+ with test.Daemon() as d:
+ # Get a URL for a pathod spec
+ url = d.p("200:b@100")
+ # ... and request it
+ r = requests.put(url)
+
+ # Check the returned data
+ assert r.status_code == 200
+ assert len(r.content) == 100
+
+ # Check pathod's internal log
+ log = d.last_log()["request"]
+ assert log["method"] == "PUT"
diff --git a/.sources/examples_setup.py b/.sources/examples_setup.py
new file mode 100644
index 00000000..5366c9ef
--- /dev/null
+++ b/.sources/examples_setup.py
@@ -0,0 +1,28 @@
+import requests
+from libpathod import test
+
+class Test:
+ """
+ Testing the requests module with
+ a pathod instance started for
+ each test.
+ """
+ def setUp(self):
+ self.d = test.Daemon()
+
+ def tearDown(self):
+ self.d.shutdown()
+
+ def test_simple(self):
+ # Get a URL for a pathod spec
+ url = self.d.p("200:b@100")
+ # ... and request it
+ r = requests.put(url)
+
+ # Check the returned data
+ assert r.status_code == 200
+ assert len(r.content) == 100
+
+ # Check pathod's internal log
+ log = self.d.last_log()["request"]
+ assert log["method"] == "PUT"
diff --git a/.sources/examples_setupall.py b/.sources/examples_setupall.py
new file mode 100644
index 00000000..c8948971
--- /dev/null
+++ b/.sources/examples_setupall.py
@@ -0,0 +1,37 @@
+import requests
+from libpathod import test
+
+class Test:
+ """
+ Testing the requests module with
+ a single pathod instance started
+ for the test suite.
+ """
+ @classmethod
+ def setUpAll(cls):
+ cls.d = test.Daemon()
+
+ @classmethod
+ def tearDownAll(cls):
+ cls.d.shutdown()
+
+ def setUp(self):
+ # Clear the pathod logs between tests
+ self.d.clear_log()
+
+ def test_simple(self):
+ # Get a URL for a pathod spec
+ url = self.d.p("200:b@100")
+ # ... and request it
+ r = requests.put(url)
+
+ # Check the returned data
+ assert r.status_code == 200
+ assert len(r.content) == 100
+
+ # Check pathod's internal log
+ log = self.d.last_log()["request"]
+ assert log["method"] == "PUT"
+
+ def test_two(self):
+ assert not self.d.log()
diff --git a/.sources/examples_test.py b/.sources/examples_test.py
deleted file mode 100644
index 1f2630e0..00000000
--- a/.sources/examples_test.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import requests
-from libpathod import test
-
-class Test:
- def setUp(self):
- self.daemon = test.Daemon()
-
- def tearDown(self):
- self.daemon.shutdown()
-
- def test_simple(self):
- path = self.daemon.p("200:b@100")
- r = requests.get(path)
- assert r.status_code == 200
- assert len(r.content) == 100
- log = self.daemon.last_log()
- assert log["request"]["method"] == "GET"
diff --git a/.sources/make b/.sources/make
index c7208bf4..e0e9d2cc 100755
--- a/.sources/make
+++ b/.sources/make
@@ -1,2 +1,4 @@
#!/bin/sh
-pygmentize -f html ./examples_test.py > ../libpathod/templates/examples_test.html
+pygmentize -f html ./examples_context.py > ../libpathod/templates/examples_context.html
+pygmentize -f html ./examples_setup.py > ../libpathod/templates/examples_setup.html
+pygmentize -f html ./examples_setupall.py > ../libpathod/templates/examples_setupall.html