Changeset 27:a9704141033a in ralphm-patches for findform.patch


Ignore:
Timestamp:
Jan 2, 2010, 3:32:52 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Ensure all modified code has unittests, add setOptions to PubSubClient?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • findform.patch

    r26 r27  
    11Move findForm to wokkel.data_form
    22
    3 diff -r ff70bda5117e wokkel/data_form.py
    4 --- a/wokkel/data_form.py       Fri Jan 01 16:03:51 2010 +0100
    5 +++ b/wokkel/data_form.py       Fri Jan 01 16:16:09 2010 +0100
    6 @@ -657,3 +657,24 @@
     3diff -r ff3064cad1af wokkel/data_form.py
     4--- a/wokkel/data_form.py       Fri Jan 01 16:16:57 2010 +0100
     5+++ b/wokkel/data_form.py       Sat Jan 02 13:44:05 2010 +0100
     6@@ -657,3 +657,25 @@
    77 
    88         for field in filtered:
    99             self.removeField(field)
     10+
    1011+
    1112+
     
    2930+
    3031+    return None
    31 diff -r ff70bda5117e wokkel/pubsub.py
    32 --- a/wokkel/pubsub.py  Fri Jan 01 16:03:51 2010 +0100
    33 +++ b/wokkel/pubsub.py  Fri Jan 01 16:16:09 2010 +0100
     32diff -r ff3064cad1af wokkel/pubsub.py
     33--- a/wokkel/pubsub.py  Fri Jan 01 16:16:57 2010 +0100
     34+++ b/wokkel/pubsub.py  Sat Jan 02 13:44:05 2010 +0100
    3435@@ -252,30 +252,6 @@
    3536         self.verb = verb
     
    9091             if form.formType == 'submit':
    9192                 self.options = form.getValues()
     93diff -r ff3064cad1af wokkel/test/test_data_form.py
     94--- a/wokkel/test/test_data_form.py     Fri Jan 01 16:16:57 2010 +0100
     95+++ b/wokkel/test/test_data_form.py     Sat Jan 02 13:44:05 2010 +0100
     96@@ -1064,3 +1064,74 @@
     97         self.assertEqual([], checked)
     98 
     99 
     100+
     101+class FindFormTest(unittest.TestCase):
     102+    """
     103+    Tests for L{data_form.findForm}.
     104+    """
     105+
     106+    def test_findForm(self):
     107+        element = domish.Element((None, 'test'))
     108+        theForm = data_form.Form('submit', formNamespace='myns')
     109+        element.addChild(theForm.toElement())
     110+        form = data_form.findForm(element, 'myns')
     111+        self.assertEqual('myns', form.formNamespace)
     112+
     113+
     114+    def test_noFormType(self):
     115+        element = domish.Element((None, 'test'))
     116+        otherForm = data_form.Form('submit')
     117+        element.addChild(otherForm.toElement())
     118+        form = data_form.findForm(element, 'myns')
     119+        self.assertIdentical(None, form)
     120+
     121+
     122+    def test_noFormTypeCancel(self):
     123+        """
     124+        Cancelled forms don't have a FORM_TYPE field, the first is returned.
     125+        """
     126+        element = domish.Element((None, 'test'))
     127+        cancelledForm = data_form.Form('cancel')
     128+        element.addChild(cancelledForm.toElement())
     129+        form = data_form.findForm(element, 'myns')
     130+        self.assertEqual('cancel', form.formType)
     131+
     132+
     133+    def test_otherFormType(self):
     134+        """
     135+        Forms with other FORM_TYPEs are ignored.
     136+        """
     137+        element = domish.Element((None, 'test'))
     138+        otherForm = data_form.Form('submit', formNamespace='otherns')
     139+        element.addChild(otherForm.toElement())
     140+        form = data_form.findForm(element, 'myns')
     141+        self.assertIdentical(None, form)
     142+
     143+
     144+    def test_otherFormTypeCancel(self):
     145+        """
     146+        Cancelled forms with another FORM_TYPE are ignored.
     147+        """
     148+        element = domish.Element((None, 'test'))
     149+        cancelledForm = data_form.Form('cancel', formNamespace='otherns')
     150+        element.addChild(cancelledForm.toElement())
     151+        form = data_form.findForm(element, 'myns')
     152+        self.assertIdentical(None, form)
     153+
     154+
     155+    def test_noElement(self):
     156+        """
     157+        When None is passed as element, None is returned.
     158+        """
     159+        element = None
     160+        form = data_form.findForm(element, 'myns')
     161+        self.assertIdentical(None, form)
     162+
     163+
     164+    def test_noForm(self):
     165+        """
     166+        When no child element is a form, None is returned.
     167+        """
     168+        element = domish.Element((None, 'test'))
     169+        form = data_form.findForm(element, 'myns')
     170+        self.assertIdentical(None, form)
Note: See TracChangeset for help on using the changeset viewer.