예제 #1
0
def test_filled(filled_mdict):
    formdata = WebobInputWrapper(filled_mdict)
    assert formdata
    assert len(formdata) == 3
    assert list(formdata) == ["a", "b", "a"]
    assert "b" in formdata
    assert "fake" not in formdata
    assert formdata.getlist("a") == ["Apple", "Cherry"]
    assert formdata.getlist("b") == ["Banana"]
    assert formdata.getlist("fake") == []
예제 #2
0
def test_filled(filled_mdict):
    formdata = WebobInputWrapper(filled_mdict)
    assert formdata
    assert len(formdata) == 3
    assert list(formdata) == ['a', 'b', 'a']
    assert 'b' in formdata
    assert 'fake' not in formdata
    assert formdata.getlist('a') == ['Apple', 'Cherry']
    assert formdata.getlist('b') == ['Banana']
    assert formdata.getlist('fake') == []
예제 #3
0
 def test_filled(self):
     formdata = WebobInputWrapper(self.filled_mdict)
     self.assertTrue(formdata)
     self.assertEqual(len(formdata), 3)
     self.assertEqual(list(formdata), ["a", "b", "a"])
     self.assertTrue("b" in formdata)
     self.assertTrue("fake" not in formdata)
     self.assertEqual(formdata.getlist("a"), ["Apple", "Cherry"])
     self.assertEqual(formdata.getlist("b"), ["Banana"])
     self.assertEqual(formdata.getlist("fake"), [])
 def test_filled(self):
     formdata = WebobInputWrapper(self.filled_mdict)
     self.assertTrue(formdata)
     self.assertEqual(len(formdata), 3)
     self.assertEqual(list(formdata), ['a', 'b', 'a'])
     self.assertTrue('b' in formdata)
     self.assertTrue('fake' not in formdata)
     self.assertEqual(formdata.getlist('a'), ['Apple', 'Cherry'])
     self.assertEqual(formdata.getlist('b'), ['Banana'])
     self.assertEqual(formdata.getlist('fake'), [])
예제 #5
0
 def wrap_formdata(self, form, formdata):
     """ work around wtform implementation """
     if formdata is not None and not hasattr(formdata, 'getlist'):
         if hasattr(formdata, 'getall'):
             return WebobInputWrapper(formdata)
         elif hasattr(formdata, '__getitem__'):  # wtform lacks this
             return DictInputWrapper(formdata)
         else:
             raise TypeError(
                 "formdata should be a (multi)dict-type wrapper that supports the 'getlist' method"
             )
     return formdata
예제 #6
0
    def wrap_formdata(self, form, formdata):
        """
        wrap_formdata allows doing custom wrappers of WTForms formdata.

        The default implementation detects webob-style multidicts and wraps
        them, otherwise passes formdata back un-changed.

        :param form: The form.
        :param formdata: Form data.
        :return: A form-input wrapper compatible with WTForms.
        """
        if formdata is not None and not hasattr(formdata, 'getlist'):
            if hasattr(formdata, 'getall'):
                return WebobInputWrapper(formdata)
            else:
                raise TypeError("formdata should be a multidict-type wrapper that supports the 'getlist' method")
        return formdata
예제 #7
0
def test_empty(empty_mdict):
    formdata = WebobInputWrapper(empty_mdict)
    assert not formdata
    assert len(formdata) == 0
    assert list(formdata) == []
    assert formdata.getlist("fake") == []
예제 #8
0
 def test_empty(self):
     formdata = WebobInputWrapper(self.empty_mdict)
     self.assertFalse(formdata)
     self.assertEqual(len(formdata), 0)
     self.assertEqual(list(formdata), [])
     self.assertEqual(formdata.getlist("fake"), [])
 def test_empty(self):
     formdata = WebobInputWrapper(self.empty_mdict)
     self.assertFalse(formdata)
     self.assertEqual(len(formdata), 0)
     self.assertEqual(list(formdata), [])
     self.assertEqual(formdata.getlist('fake'), [])