mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
Tests for wbxml
This commit is contained in:
parent
8b31f5c324
commit
bd8a869118
@ -21,7 +21,6 @@ exclude_lines =
|
||||
|
||||
[tool:full_coverage]
|
||||
exclude =
|
||||
mitmproxy/contentviews/wbxml.py
|
||||
mitmproxy/proxy/protocol/
|
||||
mitmproxy/proxy/config.py
|
||||
mitmproxy/proxy/root_context.py
|
||||
@ -39,7 +38,6 @@ exclude =
|
||||
mitmproxy/addons/onboardingapp/app.py
|
||||
mitmproxy/addons/termlog.py
|
||||
mitmproxy/contentviews/base.py
|
||||
mitmproxy/contentviews/wbxml.py
|
||||
mitmproxy/controller.py
|
||||
mitmproxy/ctx.py
|
||||
mitmproxy/exceptions.py
|
||||
|
@ -1 +1,21 @@
|
||||
# TODO: write tests
|
||||
from mitmproxy.contentviews import wbxml
|
||||
from mitmproxy.test import tutils
|
||||
from . import full_eval
|
||||
|
||||
data = tutils.test_data.push("mitmproxy/contentviews/test_wbxml_data/")
|
||||
|
||||
|
||||
def test_wbxml():
|
||||
v = full_eval(wbxml.ViewWBXML())
|
||||
|
||||
assert v(b'\x03\x01\x6A\x00') == ('WBXML', [[('text', '<?xml version="1.0" ?>')]])
|
||||
assert v(b'foo') is None
|
||||
|
||||
path = data.path("data.wbxml") # File taken from https://github.com/davidpshaw/PyWBXMLDecoder/tree/master/wbxml_samples
|
||||
with open(path, 'rb') as f:
|
||||
input = f.read()
|
||||
with open("-formatted.".join(path.rsplit(".", 1))) as f:
|
||||
expected = f.read()
|
||||
|
||||
p = wbxml.ASCommandResponse.ASCommandResponse(input)
|
||||
assert p.xmlString == expected
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Sync>
|
||||
<Collections>
|
||||
<Collection>
|
||||
<SyncKey>1509029063</SyncKey>
|
||||
<CollectionId>7</CollectionId>
|
||||
<Status>1</Status>
|
||||
</Collection>
|
||||
</Collections>
|
||||
</Sync>
|
BIN
test/mitmproxy/contentviews/test_wbxml_data/data.wbxml
Normal file
BIN
test/mitmproxy/contentviews/test_wbxml_data/data.wbxml
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user