Commits

megamahi committed 44b5084

Initial tests

Comments (0)

Files changed (2)

+import tw2.core as twc
+import tw2.tinymce
+
+from nose.tools import eq_
+
+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.tinymce.TinyMCEWidget(id='foobar')
+    w.display()
+
+    js_calls = filter(lambda x: "JSFuncCall" in str(x), w.resources)
+
+    assert(len(js_calls) == 1)
+
+    for js_call in js_calls:
+        eq_(js_call.src,"""tinyMCE.init({"theme_advanced_toolbar_location": "top", "theme_advanced_toolbar_align": "center", "paste_auto_cleanup_on_paste": true, "language": "en", "paste_convert_headers_to_strong": false, "theme_advanced_resizing": true, "theme_advanced_statusbar_location": "bottom", "paste_strip_class_attributes": "all", "theme": "advanced", "elements": "foobar", "mode": "exact", "plugins": "advimage", "paste_use_dialog": false, "extended_valid_elements": "a[href|target|name]"})""")

tests/test_widget.py

-from tw.core.testutil import WidgetTestCase
-from tw.tinymce import *
+from tw2.core.testbase import  WidgetTest
+import tw2.tinymce
 
-class TestWidget(WidgetTestCase):
+class TestDemoWidget(WidgetTest):
     # place your widget at the TestWidget attribute
-    TestWidget = Tinymce
-    # Initilization args. go here 
-    widget_kw = {}
+    widget = tw2.tinymce.TinyMCEWidget
 
-    def test_render(self):
-        # Asserts 'foo' and 'test' (the test widget's id) appear in rendered 
-        # string when 'foo' is passed as value to render
-        self.assertInOutput(['foo', 'test'], "foo")
-        # Asserts 'ohlalala' does not appear in rendered string when render 
-        # is called without args
-        self.assertNotInOutput(['ohlalala'])
+    # Initilization args. go here
+    attrs = {'id' : 'test_tinymce'}
+    params = {}
+    expected = """<textarea rows="25" cols="79" id="test_tinymce" name="test_tinymce"></textarea>"""
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.