Commits

megamahi  committed cc1322a

Added tests for new Widget

  • Participants
  • Parent commits f772bb7

Comments (0)

Files changed (3)

File tests/test_exceptions.py

     twc.core.request_local()['middleware'] = twc.make_middleware()
 
 def test_exception_nodata_url():
-    w = tw2.dyntext.DynamicTextWidget(id='foobar')
+    w = tw2.dyntext.PollingDynamicTextWidget(id='foobar')
     try:
         w.display()
         assert(False)
         assert(str(e) == 'DynamicTextWidget data_url parameter must be set')
 
 def test_exception_bad_data_url():
-    w = tw2.dyntext.DynamicTextWidget(id='foobar', data_url=dict())
+    w = tw2.dyntext.PollingDynamicTextWidget(id='foobar', data_url=dict())
     try:
         w.display()
         assert(False)

File tests/test_js.py

     twc.core.request_local()['middleware'] = twc.make_middleware()
 
 def test_js_call():
-    w = tw2.dyntext.DynamicTextWidget(id='foobar', data_url="/herp/derp")
+    w = tw2.dyntext.PollingDynamicTextWidget(id='foobar', data_url="/herp/derp")
     w.display()
 
     js_calls = filter(lambda x: "JSFuncCall" in str(x), w.resources)

File tests/test_widget.py

 
 class TestDemoWidget(WidgetTest):
     # place your widget at the TestWidget attribute
+    widget = tw2.dyntext.PollingDynamicTextWidget
+
+    # Initilization args. go here
+    attrs = {'id' : 'affected_count'}
+    params = {'data_url' : '/stats/affected_count'}
+    expected = """<span id="affected_count"></span>"""
+
+
+class TestDemoWidget(WidgetTest):
+    # place your widget at the TestWidget attribute
     widget = tw2.dyntext.DynamicTextWidget
 
     # Initilization args. go here
     attrs = {'id' : 'affected_count'}
-    params = {'data_url' : '/stats/affected_count'}
-    expected = """<span id="affected_count"></span>"""
+    params = {'initial_text' : 'test'}
+    expected = """<span id="affected_count">test</span>"""