Ignore:
Timestamp:
Jan 5, 2010, 2:55:40 PM (12 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Move findForm to wokkel.data_form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_data_form.py

    r79 r80  
    11521152
    11531153
     1154
     1155class FindFormTest(unittest.TestCase):
     1156    """
     1157    Tests for L{data_form.findForm}.
     1158    """
     1159
     1160    def test_findForm(self):
     1161        element = domish.Element((None, 'test'))
     1162        theForm = data_form.Form('submit', formNamespace='myns')
     1163        element.addChild(theForm.toElement())
     1164        form = data_form.findForm(element, 'myns')
     1165        self.assertEqual('myns', form.formNamespace)
     1166
     1167
     1168    def test_noFormType(self):
     1169        element = domish.Element((None, 'test'))
     1170        otherForm = data_form.Form('submit')
     1171        element.addChild(otherForm.toElement())
     1172        form = data_form.findForm(element, 'myns')
     1173        self.assertIdentical(None, form)
     1174
     1175
     1176    def test_noFormTypeCancel(self):
     1177        """
     1178        Cancelled forms don't have a FORM_TYPE field, the first is returned.
     1179        """
     1180        element = domish.Element((None, 'test'))
     1181        cancelledForm = data_form.Form('cancel')
     1182        element.addChild(cancelledForm.toElement())
     1183        form = data_form.findForm(element, 'myns')
     1184        self.assertEqual('cancel', form.formType)
     1185
     1186
     1187    def test_otherFormType(self):
     1188        """
     1189        Forms with other FORM_TYPEs are ignored.
     1190        """
     1191        element = domish.Element((None, 'test'))
     1192        otherForm = data_form.Form('submit', formNamespace='otherns')
     1193        element.addChild(otherForm.toElement())
     1194        form = data_form.findForm(element, 'myns')
     1195        self.assertIdentical(None, form)
     1196
     1197
     1198    def test_otherFormTypeCancel(self):
     1199        """
     1200        Cancelled forms with another FORM_TYPE are ignored.
     1201        """
     1202        element = domish.Element((None, 'test'))
     1203        cancelledForm = data_form.Form('cancel', formNamespace='otherns')
     1204        element.addChild(cancelledForm.toElement())
     1205        form = data_form.findForm(element, 'myns')
     1206        self.assertIdentical(None, form)
     1207
     1208
     1209    def test_noElement(self):
     1210        """
     1211        When None is passed as element, None is returned.
     1212        """
     1213        element = None
     1214        form = data_form.findForm(element, 'myns')
     1215        self.assertIdentical(None, form)
     1216
     1217
     1218    def test_noForm(self):
     1219        """
     1220        When no child element is a form, None is returned.
     1221        """
     1222        element = domish.Element((None, 'test'))
     1223        form = data_form.findForm(element, 'myns')
     1224        self.assertIdentical(None, form)
    11541225    def test_typeCheckNoFieldDefs(self):
    11551226        """
Note: See TracChangeset for help on using the changeset viewer.