aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/io/test_compat.py
blob: 341906ca9ce1048cdab060f264d2f36f3a8fb3ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest

from mitmproxy import io
from mitmproxy import exceptions


def test_load(tdata):
    with open(tdata.path("mitmproxy/data/dumpfile-011.bin"), "rb") as f:
        flow_reader = io.FlowReader(f)
        flows = list(flow_reader.stream())
        assert len(flows) == 1
        assert flows[0].request.url == "https://example.com/"


def test_load_018(tdata):
    with open(tdata.path("mitmproxy/data/dumpfile-018.bin"), "rb") as f:
        flow_reader = io.FlowReader(f)
        flows = list(flow_reader.stream())
        assert len(flows) == 1
        assert flows[0].request.url == "https://www.example.com/"


def test_cannot_convert(tdata):
    with open(tdata.path("mitmproxy/data/dumpfile-010.bin"), "rb") as f:
        flow_reader = io.FlowReader(f)
        with pytest.raises(exceptions.FlowReadException):
            list(flow_reader.stream())