[Checkins] SVN: grokui.admin/trunk/src/grokui/admin/tests/brokenapps.py Add tests for https://bugs.launchpad.net/grok/+bug/638763.
Uli Fouquet
uli at gnufix.de
Wed Sep 15 05:48:24 EDT 2010
Log message for revision 116430:
Add tests for https://bugs.launchpad.net/grok/+bug/638763.
Changed:
A grokui.admin/trunk/src/grokui/admin/tests/brokenapps.py
-=-
Added: grokui.admin/trunk/src/grokui/admin/tests/brokenapps.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/tests/brokenapps.py (rev 0)
+++ grokui.admin/trunk/src/grokui/admin/tests/brokenapps.py 2010-09-15 09:48:24 UTC (rev 116430)
@@ -0,0 +1,67 @@
+"""
+Broken applications
+===================
+
+When some broken application raises DuplicationErrors during creation,
+these problem will not be hidden away.
+
+We first setup the environment:
+
+ >>> from zope.app.wsgi.testlayer import Browser
+ >>> browser = Browser()
+ >>> #print dir(browser)
+ >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+We have an application type available, which raises DuplicationError
+during creation intentionally:
+
+ >>> browser.open('http://localhost/++grokui++/applications')
+ >>> 'IntentionallyBrokenApp' in browser.contents
+ True
+
+If we try to add an application of that type, the traceback will be
+visible:
+
+ >>> browser.handleErrors = False
+ >>> subform = browser.getForm(
+ ... name='grokui.admin.tests.brokenapps.IntentionallyBrokenApp')
+ >>> subform.getControl(name='name').value = 'mybrokenapp'
+ >>> subform.getControl('Create').click()
+ Traceback (most recent call last):
+ ...
+ DuplicationError: Intentional DuplicationError
+
+If, however, we try to add two working apps under same name, the UI
+will inform us of the problem (without a traceback):
+
+ >>> browser.open('http://localhost/++grokui++/applications')
+ >>> subform = browser.getForm(
+ ... name='grokui.admin.tests.brokenapps.WorkingApp')
+ >>> subform.getControl(name='name').value = 'somename'
+ >>> subform.getControl('Create').click()
+
+ >>> subform = browser.getForm(
+ ... name='grokui.admin.tests.brokenapps.WorkingApp')
+ >>> subform.getControl(name='name').value = 'somename'
+ >>> subform.getControl('Create').click()
+
+ >>> print browser.contents
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ ...
+ ...Name `somename` already in use. Please choose another name...
+ ...
+
+"""
+import grok
+from zope.exceptions import DuplicationError
+
+class IntentionallyBrokenApp(grok.Application, grok.Container):
+ """An application that intentionally raises DuplicationError.
+ """
+
+ def __init__(self, *args, **kw):
+ raise DuplicationError('Intentional DuplicationError')
+
+class WorkingApp(grok.Application, grok.Container):
+ """A working app.
+ """
More information about the checkins
mailing list