diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2017-05-26 18:38:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-26 18:38:24 +0200 |
commit | f5eaddb12c1b6775c8f72e56abd10ede2b877755 (patch) | |
tree | 8741974730e75b3234f6ce3144771f917b6d12a3 | |
parent | e5414ae2d3c124b192fd057ed44441ca5298a87f (diff) | |
parent | bd8a8691184cad4325f6b8609863bd9311f39a81 (diff) | |
download | mitmproxy-f5eaddb12c1b6775c8f72e56abd10ede2b877755.tar.gz mitmproxy-f5eaddb12c1b6775c8f72e56abd10ede2b877755.tar.bz2 mitmproxy-f5eaddb12c1b6775c8f72e56abd10ede2b877755.zip |
Merge pull request #2346 from ujjwal96/test-coverage
Tests for wbxml
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | test/mitmproxy/contentviews/test_wbxml.py | 22 | ||||
-rw-r--r-- | test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml | 10 | ||||
-rw-r--r-- | test/mitmproxy/contentviews/test_wbxml_data/data.wbxml | bin | 0 -> 34 bytes |
4 files changed, 31 insertions, 3 deletions
@@ -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 diff --git a/test/mitmproxy/contentviews/test_wbxml.py b/test/mitmproxy/contentviews/test_wbxml.py index 777ab4dd..09c770e7 100644 --- a/test/mitmproxy/contentviews/test_wbxml.py +++ b/test/mitmproxy/contentviews/test_wbxml.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 diff --git a/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml b/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml new file mode 100644 index 00000000..fed293bd --- /dev/null +++ b/test/mitmproxy/contentviews/test_wbxml_data/data-formatted.wbxml @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<Sync> + <Collections> + <Collection> + <SyncKey>1509029063</SyncKey> + <CollectionId>7</CollectionId> + <Status>1</Status> + </Collection> + </Collections> +</Sync> diff --git a/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml b/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml Binary files differnew file mode 100644 index 00000000..7c7a2004 --- /dev/null +++ b/test/mitmproxy/contentviews/test_wbxml_data/data.wbxml |