def test_form_params_method(self): from memphis.form.form import Form form = Form(None, None) form.method = 'params' params = {'post': 'info'} form.params = params self.assertIs(form.getParams(), params)
def test_getContent(self): from memphis.form.form import Form request = DummyRequest() form = Form(None, request) self.assertIsNone(form.getContent()) form_content = {} form.content = form_content self.assertIs(form.getContent(), form_content)
def test_basics(self): from memphis.form.form import Form request = DummyRequest() form = Form(None, request) request.url = '/test/form' self.assertEqual(form.action, request.url) self.assertEqual(form.name, 'form') form = Form(None, request) form.prefix = 'my.test.form.' self.assertEqual(form.name, 'my.test.form') self.assertEqual(form.id, 'my-test-form')
def test_getParams(self): from memphis.form.form import Form, DisplayForm request = DummyRequest() form = Form(None, request) disp_form = DisplayForm(None, request) self.assertEqual(form.method, 'post') post = {'post': 'info'} request.POST = post self.assertIs(form.getParams(), post) self.assertIs(disp_form.getParams(), Form.params) get = {'get': 'info'} request.GET = get form.method = 'get' self.assertIs(form.getParams(), get) form.method = 'unknown' self.assertEqual(dict(form.getParams()), {})