MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_contentencode

Method test_contentencode

examples/contrib/test_jsondump.py:41–54  ·  view source on GitHub ↗
(self, tmpdir)

Source from the content-addressed store, hash-verified

39 assert entry["response"]["content"] == "message"
40
41 def test_contentencode(self, tmpdir):
42 with taddons.context() as tctx:
43 a = tctx.script(example_dir.path("complex/jsondump.py"))
44 path = str(tmpdir.join("jsondump.out"))
45 content = b"foo" + b"\xff" * 10
46 tctx.configure(a, dump_destination=path, dump_encodecontent=True)
47
48 tctx.invoke(a, "response", self.flow(resp_content=content))
49 tctx.invoke(a, "done")
50 with open(path) as inp:
51 entry = json.loads(inp.readline())
52 assert entry["response"]["content"] == base64.b64encode(content).decode(
53 "utf-8"
54 )
55
56 def test_http(self, tmpdir):
57 with requests_mock.Mocker() as mock:

Callers

nothing calls this directly

Calls 8

flowMethod · 0.95
contextMethod · 0.80
scriptMethod · 0.80
loadsMethod · 0.80
pathMethod · 0.45
joinMethod · 0.45
configureMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected