mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Use classes to test a command, move code to separate methods under
classes
This commit is contained in:
parent
0576f579ed
commit
5f044d03b7
@ -20,21 +20,27 @@ req_patch = netlib.tutils.treq(
|
||||
)
|
||||
|
||||
|
||||
def test_curl_command():
|
||||
class TestExportCurlCommand():
|
||||
|
||||
def test_get(self):
|
||||
flow = tutils.tflow(req=req_get)
|
||||
result = """curl -H 'header:qvalue' -H 'content-length:7' 'http://address/path'"""
|
||||
assert flow_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
|
||||
|
||||
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
|
||||
|
||||
|
||||
def test_python_code():
|
||||
class TestExportPythonCode():
|
||||
|
||||
def test_get(self):
|
||||
flow = tutils.tflow(req=req_get)
|
||||
result = dedent("""
|
||||
import requests
|
||||
@ -56,6 +62,7 @@ def test_python_code():
|
||||
""").strip()
|
||||
assert flow_export.python_code(flow) == result
|
||||
|
||||
def test_post(self):
|
||||
flow = tutils.tflow(req=req_post)
|
||||
result = dedent("""
|
||||
import requests
|
||||
@ -74,6 +81,7 @@ def test_python_code():
|
||||
""").strip()
|
||||
assert flow_export.python_code(flow) == result
|
||||
|
||||
def test_patch(self):
|
||||
flow = tutils.tflow(req=req_patch)
|
||||
result = dedent("""
|
||||
import requests
|
||||
@ -104,7 +112,9 @@ def test_python_code():
|
||||
assert flow_export.python_code(flow) == result
|
||||
|
||||
|
||||
def test_raw_request():
|
||||
def TestRawRequest():
|
||||
|
||||
def test_get(self):
|
||||
flow = tutils.tflow(req=req_get)
|
||||
result = dedent("""
|
||||
GET /path HTTP/1.1\r
|
||||
@ -115,6 +125,7 @@ def test_raw_request():
|
||||
""").strip(" ").lstrip()
|
||||
assert flow_export.raw_request(flow) == result
|
||||
|
||||
def test_post(self):
|
||||
flow = tutils.tflow(req=req_post)
|
||||
result = dedent("""
|
||||
POST /path HTTP/1.1\r
|
||||
@ -124,6 +135,7 @@ def test_raw_request():
|
||||
""").strip()
|
||||
assert flow_export.raw_request(flow) == result
|
||||
|
||||
def test_patch(self):
|
||||
flow = tutils.tflow(req=req_patch)
|
||||
result = dedent("""
|
||||
PATCH /path?query=param HTTP/1.1\r
|
||||
|
Loading…
Reference in New Issue
Block a user