aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-05-31 09:45:37 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-05-31 09:45:37 +1200
commit3e8345ee93c0ac96d8c1a081329f7ddcb375e72d (patch)
tree3f1eb98388daf91659f0c4fe2fd51d6fc7cd1c71 /test
parent4f0657bc22b23db88870df92a519502c6e12db80 (diff)
parente3d7224e5d9c9e396e839b48c94357a896e670ae (diff)
downloadmitmproxy-3e8345ee93c0ac96d8c1a081329f7ddcb375e72d.tar.gz
mitmproxy-3e8345ee93c0ac96d8c1a081329f7ddcb375e72d.tar.bz2
mitmproxy-3e8345ee93c0ac96d8c1a081329f7ddcb375e72d.zip
Merge branch 'flow-module-2' of https://github.com/mhils/mitmproxy into mhils-flow-module-2
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_flow_export.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py
index 03405757..9a263b1b 100644
--- a/test/mitmproxy/test_flow_export.py
+++ b/test/mitmproxy/test_flow_export.py
@@ -3,7 +3,7 @@ import re
import netlib.tutils
from netlib.http import Headers
-from mitmproxy import flow_export
+from mitmproxy.flow import export # heh
from . import tutils
@@ -36,38 +36,38 @@ class TestExportCurlCommand():
def test_get(self):
flow = tutils.tflow(req=req_get())
result = """curl -H 'header:qvalue' -H 'content-length:7' 'http://address/path?a=foo&a=bar&b=baz'"""
- assert flow_export.curl_command(flow) == result
+ assert export.curl_command(flow) == result
def test_post(self):
flow = tutils.tflow(req=req_post())
result = """curl -X POST 'http://address/path' --data-binary 'content'"""
- assert flow_export.curl_command(flow) == result
+ assert export.curl_command(flow) == result
def test_patch(self):
flow = tutils.tflow(req=req_patch())
result = """curl -H 'header:qvalue' -H 'content-length:7' -X PATCH 'http://address/path?query=param' --data-binary 'content'"""
- assert flow_export.curl_command(flow) == result
+ assert export.curl_command(flow) == result
class TestExportPythonCode():
def test_get(self):
flow = tutils.tflow(req=req_get())
- python_equals("data/test_flow_export/python_get.py", flow_export.python_code(flow))
+ python_equals("data/test_flow_export/python_get.py", export.python_code(flow))
def test_post(self):
flow = tutils.tflow(req=req_post())
- python_equals("data/test_flow_export/python_post.py", flow_export.python_code(flow))
+ python_equals("data/test_flow_export/python_post.py", export.python_code(flow))
def test_post_json(self):
p = req_post()
p.content = '{"name": "example", "email": "example@example.com"}'
p.headers = Headers(content_type="application/json")
flow = tutils.tflow(req=p)
- python_equals("data/test_flow_export/python_post_json.py", flow_export.python_code(flow))
+ python_equals("data/test_flow_export/python_post_json.py", export.python_code(flow))
def test_patch(self):
flow = tutils.tflow(req=req_patch())
- python_equals("data/test_flow_export/python_patch.py", flow_export.python_code(flow))
+ python_equals("data/test_flow_export/python_patch.py", export.python_code(flow))
class TestRawRequest():
@@ -80,7 +80,7 @@ class TestRawRequest():
host: address:22\r
\r
""").strip(" ").lstrip()
- assert flow_export.raw_request(flow) == result
+ assert export.raw_request(flow) == result
def test_post(self):
flow = tutils.tflow(req=req_post())
@@ -90,7 +90,7 @@ class TestRawRequest():
\r
content
""").strip()
- assert flow_export.raw_request(flow) == result
+ assert export.raw_request(flow) == result
def test_patch(self):
flow = tutils.tflow(req=req_patch())
@@ -102,54 +102,54 @@ class TestRawRequest():
\r
content
""").strip()
- assert flow_export.raw_request(flow) == result
+ assert export.raw_request(flow) == result
class TestExportLocustCode():
def test_get(self):
flow = tutils.tflow(req=req_get())
- python_equals("data/test_flow_export/locust_get.py", flow_export.locust_code(flow))
+ python_equals("data/test_flow_export/locust_get.py", export.locust_code(flow))
def test_post(self):
p = req_post()
p.content = '''content'''
p.headers = ''
flow = tutils.tflow(req=p)
- python_equals("data/test_flow_export/locust_post.py", flow_export.locust_code(flow))
+ python_equals("data/test_flow_export/locust_post.py", export.locust_code(flow))
def test_patch(self):
flow = tutils.tflow(req=req_patch())
- python_equals("data/test_flow_export/locust_patch.py", flow_export.locust_code(flow))
+ python_equals("data/test_flow_export/locust_patch.py", export.locust_code(flow))
class TestExportLocustTask():
def test_get(self):
flow = tutils.tflow(req=req_get())
- python_equals("data/test_flow_export/locust_task_get.py", flow_export.locust_task(flow))
+ python_equals("data/test_flow_export/locust_task_get.py", export.locust_task(flow))
def test_post(self):
flow = tutils.tflow(req=req_post())
- python_equals("data/test_flow_export/locust_task_post.py", flow_export.locust_task(flow))
+ python_equals("data/test_flow_export/locust_task_post.py", export.locust_task(flow))
def test_patch(self):
flow = tutils.tflow(req=req_patch())
- python_equals("data/test_flow_export/locust_task_patch.py", flow_export.locust_task(flow))
+ python_equals("data/test_flow_export/locust_task_patch.py", export.locust_task(flow))
class TestIsJson():
def test_empty(self):
- assert flow_export.is_json(None, None) is False
+ assert export.is_json(None, None) is False
def test_json_type(self):
headers = Headers(content_type="application/json")
- assert flow_export.is_json(headers, "foobar") is False
+ assert export.is_json(headers, "foobar") is False
def test_valid(self):
headers = Headers(content_type="application/foobar")
- j = flow_export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
+ j = export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
assert j is False
def test_valid2(self):
headers = Headers(content_type="application/json")
- j = flow_export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
+ j = export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
assert isinstance(j, dict)