def test_update_json_collection_form_not_fail(self): request = TestRequest(stdin=StringIO('{}')) f = form.ItemForm(self.item, request) core.update_json_collection_form(f) # should not fail. request = TestRequest(stdin=StringIO('')) f = form.ItemForm(self.item, request) core.update_json_collection_form(f)
def update(self): """ Convert JSON input into standard request. """ _disable_csrf_for_webservices(self) update_json_collection_form(self) super(JsonCollectionFormMixin, self).update() self._jc_template = formfields_to_collection_template(self) return None
def update(self): """ Convert JSON input into standard request. """ # XXX at some point we need to consider the security and how # this might be vulnerable to XSS (for browsers that do not have # origin policy support). self.disableAuthenticator = True update_json_collection_form(self) super(JsonCollectionFormMixin, self).update() self._jc_template = formfields_to_collection_template(self) return None
def test_update_json_collection_form(self): request = TestRequest(stdin=StringIO('''{ "template": { "data": [ { "name": "form.widgets.item_id", "value": 2 }, { "name": "form.widgets.name", "value": "The Name" } ] }}''')) f = form.ItemForm(self.item, request) core.update_json_collection_form(f) self.assertEqual(request.form['form.widgets.item_id'], 2) self.assertEqual(request.form['form.widgets.name'], 'The Name')