Permalink
Browse files

More unit tests

  • Loading branch information...
1 parent 40d84bc commit 7798a31174b23da9b4cdfe9e9abbf1c0388a5b08 @gregjurman gregjurman committed Feb 21, 2012
Showing with 41 additions and 1 deletion.
  1. +39 −0 tests/test_exceptions.py
  2. +2 −1 tests/test_widget.py
View
39 tests/test_exceptions.py
@@ -0,0 +1,39 @@
+import tw2.core as twc
+import tw2.dyntext
+
+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_exception_nodata_url():
+ w = tw2.dyntext.DynamicTextWidget(id='foobar')
+ try:
+ w.display()
+ assert(False)
+ except ValueError as e:
+ 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())
+ try:
+ w.display()
+ assert(False)
+ except ValueError as e:
+ assert(str(e) == 'DynamicTextWidget data_url parameter must be a string')
View
3 tests/test_widget.py
@@ -1,5 +1,6 @@
from tw2.core.testbase import WidgetTest
-from tw2.dyntext import *
+from tw2.dyntext import DynamicTextWidget
+from nose.tools import raises
class TestDemoWidget(WidgetTest):
# place your widget at the TestWidget attribute

0 comments on commit 7798a31

Please sign in to comment.