aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-05-22 10:00:35 +0200
committerGitHub <noreply@github.com>2017-05-22 10:00:35 +0200
commit5626c384ab61dc0cd08efe70e6416e63f8221847 (patch)
tree844cd1d5305f6bcc830381f04923fd08ad83f8ac /test
parentaf0ad494348d0f2d773232b5913d5c86787e39f5 (diff)
parent546bac68d471d23bee70b549a5179a775fded4fc (diff)
downloadmitmproxy-5626c384ab61dc0cd08efe70e6416e63f8221847.tar.gz
mitmproxy-5626c384ab61dc0cd08efe70e6416e63f8221847.tar.bz2
mitmproxy-5626c384ab61dc0cd08efe70e6416e63f8221847.zip
Merge pull request #2342 from MatthewShao/jest-dev
[web] Add _flow.js for component tests.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/tools/web/test_app.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py
index 2b6181d3..5427b995 100644
--- a/test/mitmproxy/tools/web/test_app.py
+++ b/test/mitmproxy/tools/web/test_app.py
@@ -1,5 +1,6 @@
import json as _json
from unittest import mock
+import os
import tornado.testing
from tornado import httpclient
@@ -275,3 +276,20 @@ class TestApp(tornado.testing.AsyncHTTPTestCase):
# trigger on_close by opening a second connection.
ws_client2 = yield websocket.websocket_connect(ws_url)
ws_client2.close()
+
+ def test_generate_tflow_js(self):
+ _tflow = app.flow_to_json(tflow.tflow(resp=True, err=True))
+ # Set some value as constant, so that _tflow.js would not change every time.
+ _tflow['client_conn']['id'] = "4a18d1a0-50a1-48dd-9aa6-d45d74282939"
+ _tflow['id'] = "d91165be-ca1f-4612-88a9-c0f8696f3e29"
+ _tflow['error']['timestamp'] = 1495370312.4814785
+ _tflow['response']['timestamp_end'] = 1495370312.4814625
+ _tflow['response']['timestamp_start'] = 1495370312.481462
+ _tflow['server_conn']['id'] = "f087e7b2-6d0a-41a8-a8f0-e1a4761395f8"
+ tflow_json = _json.dumps(_tflow, indent=4, sort_keys=True)
+ here = os.path.abspath(os.path.dirname(__file__))
+ web_root = os.path.join(here, os.pardir, os.pardir, os.pardir, os.pardir, 'web')
+ tflow_path = os.path.join(web_root, 'src/js/__tests__/ducks/_tflow.js')
+ content = """export default function(){{\n return {tflow_json}\n}}""".format(tflow_json=tflow_json)
+ with open(tflow_path, 'w') as f:
+ f.write(content)