MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_flow_set

Function test_flow_set

test/mitmproxy/addons/test_core.py:68–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66
67
68def test_flow_set():
69 sa = core.Core()
70 with taddons.context(loadcore=False):
71 f = tflow.tflow(resp=True)
72 assert sa.flow_set_options()
73
74 assert f.request.method != "post"
75 sa.flow_set([f], "method", "post")
76 assert f.request.method == "POST"
77
78 assert f.request.host != "testhost"
79 sa.flow_set([f], "host", "testhost")
80 assert f.request.host == "testhost"
81
82 assert f.request.path != "/test/path"
83 sa.flow_set([f], "path", "/test/path")
84 assert f.request.path == "/test/path"
85
86 assert f.request.url != "http://foo.com/bar"
87 sa.flow_set([f], "url", "http://foo.com/bar")
88 assert f.request.url == "http://foo.com/bar"
89 with pytest.raises(exceptions.CommandError):
90 sa.flow_set([f], "url", "oink")
91
92 assert f.response.status_code != 404
93 sa.flow_set([f], "status_code", "404")
94 assert f.response.status_code == 404
95 assert f.response.reason == "Not Found"
96 with pytest.raises(exceptions.CommandError):
97 sa.flow_set([f], "status_code", "oink")
98
99 assert f.response.reason != "foo"
100 sa.flow_set([f], "reason", "foo")
101 assert f.response.reason == "foo"
102
103
104def test_encoding():

Callers

nothing calls this directly

Calls 3

flow_set_optionsMethod · 0.95
flow_setMethod · 0.95
contextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…