megamahi avatar megamahi committed 56f57bc

Added JS Call test

Comments (0)

Files changed (1)

+import tw2.core as twc
+import tw2.qrcode
+
+def request_local_tst():
+    global _request_local, _request_id
+# if _request_id is None:
+# raise KeyError('must be in a request')
+    if _request_local == None:
+        _request_local = {}
+    try:
+        return _request_local[_request_id]
+    except KeyError:
+        rl_data = {}
+        _request_local[_request_id] = rl_data
+        return rl_data
+
+twc.core.request_local = request_local_tst
+_request_local = {}
+_request_id = 'whatever'
+
+def setup():
+    twc.core.request_local = request_local_tst
+    twc.core.request_local()['middleware'] = twc.make_middleware()
+
+def test_js_call():
+    w = tw2.qrcode.QRCodeWidget(id='foobar', data="Herp derp", qr_type=4)
+    w.display()
+
+    js_calls = filter(lambda x: "JSFuncCall" in str(x), w.resources)
+
+    assert(len(js_calls) > 0)
+
+    for js_call in js_calls:
+        print js_call.src
+        assert(js_call.src == """draw_qrcode("foobar", "Herp derp", 4, QRErrorCorrectLevel.H, 160)""")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.