diff options
Diffstat (limited to 'test/mitmproxy/test_flow_export.py')
-rw-r--r-- | test/mitmproxy/test_flow_export.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py index af3713de..03405757 100644 --- a/test/mitmproxy/test_flow_export.py +++ b/test/mitmproxy/test_flow_export.py @@ -20,11 +20,16 @@ def python_equals(testdata, text): assert clean_blanks(text).rstrip() == clean_blanks(d).rstrip() -req_get = lambda: netlib.tutils.treq(method='GET', content='', path=b"/path?a=foo&a=bar&b=baz") +def req_get(): + return netlib.tutils.treq(method='GET', content='', path=b"/path?a=foo&a=bar&b=baz") -req_post = lambda: netlib.tutils.treq(method='POST', headers=()) -req_patch = lambda: netlib.tutils.treq(method='PATCH', path=b"/path?query=param") +def req_post(): + return netlib.tutils.treq(method='POST', headers=()) + + +def req_patch(): + return netlib.tutils.treq(method='PATCH', path=b"/path?query=param") class TestExportCurlCommand(): @@ -47,22 +52,22 @@ class TestExportCurlCommand(): class TestExportPythonCode(): def test_get(self): flow = tutils.tflow(req=req_get()) - python_equals("test_flow_export/python_get.py", flow_export.python_code(flow)) + python_equals("data/test_flow_export/python_get.py", flow_export.python_code(flow)) def test_post(self): flow = tutils.tflow(req=req_post()) - python_equals("test_flow_export/python_post.py", flow_export.python_code(flow)) + python_equals("data/test_flow_export/python_post.py", flow_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("test_flow_export/python_post_json.py", flow_export.python_code(flow)) + python_equals("data/test_flow_export/python_post_json.py", flow_export.python_code(flow)) def test_patch(self): flow = tutils.tflow(req=req_patch()) - python_equals("test_flow_export/python_patch.py", flow_export.python_code(flow)) + python_equals("data/test_flow_export/python_patch.py", flow_export.python_code(flow)) class TestRawRequest(): @@ -103,32 +108,32 @@ class TestRawRequest(): class TestExportLocustCode(): def test_get(self): flow = tutils.tflow(req=req_get()) - python_equals("test_flow_export/locust_get.py", flow_export.locust_code(flow)) + python_equals("data/test_flow_export/locust_get.py", flow_export.locust_code(flow)) def test_post(self): p = req_post() p.content = '''content''' p.headers = '' flow = tutils.tflow(req=p) - python_equals("test_flow_export/locust_post.py", flow_export.locust_code(flow)) + python_equals("data/test_flow_export/locust_post.py", flow_export.locust_code(flow)) def test_patch(self): flow = tutils.tflow(req=req_patch()) - python_equals("test_flow_export/locust_patch.py", flow_export.locust_code(flow)) + python_equals("data/test_flow_export/locust_patch.py", flow_export.locust_code(flow)) class TestExportLocustTask(): def test_get(self): flow = tutils.tflow(req=req_get()) - python_equals("test_flow_export/locust_task_get.py", flow_export.locust_task(flow)) + python_equals("data/test_flow_export/locust_task_get.py", flow_export.locust_task(flow)) def test_post(self): flow = tutils.tflow(req=req_post()) - python_equals("test_flow_export/locust_task_post.py", flow_export.locust_task(flow)) + python_equals("data/test_flow_export/locust_task_post.py", flow_export.locust_task(flow)) def test_patch(self): flow = tutils.tflow(req=req_patch()) - python_equals("test_flow_export/locust_task_patch.py", flow_export.locust_task(flow)) + python_equals("data/test_flow_export/locust_task_patch.py", flow_export.locust_task(flow)) class TestIsJson(): @@ -144,7 +149,7 @@ class TestIsJson(): j = flow_export.is_json(headers, '{"name": "example", "email": "example@example.com"}') assert j is False - def test_valid(self): + def test_valid2(self): headers = Headers(content_type="application/json") j = flow_export.is_json(headers, '{"name": "example", "email": "example@example.com"}') assert isinstance(j, dict) |