def test_editform_basics(self): from ptahcms.forms import EditForm content = Content() form = EditForm(content, DummyRequest()) form.update() self.assertIs(form.fields, Content.__type__.fieldset) self.assertIs(form.tinfo, Content.__type__) self.assertEqual(form.label,'Modify content: %s'%Content.__type__.title)
def test_editform_basics(self): from ptahcms.forms import EditForm content = Content() form = EditForm(content, DummyRequest()) form.update() self.assertIs(form.fields, Content.__type__.fieldset) self.assertIs(form.tinfo, Content.__type__) self.assertEqual(form.label, 'Modify content: %s' % Content.__type__.title)
def test_editform_save_errors(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() form = EditForm(content, DummyRequest( POST = {'form.buttons.save': 'Save'})) form.update() self.assertIn('Please fix indicated errors.', ptah.view.render_messages(form.request))
def test_editform_save_errors(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() form = EditForm(content, DummyRequest(POST={'form.buttons.save': 'Save'})) form.update() self.assertIn('Please fix indicated errors.', ptah.view.render_messages(form.request))
def test_editform_form_content(self): from ptahcms.forms import EditForm content = Content() content.title = 'Test content' content.description = 'Desc' form = EditForm(content, DummyRequest()) form.update() data = form.form_content() self.assertEqual(data['title'], 'Test content') self.assertEqual(data['description'], 'Desc')
def test_editform_apply_changes(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() content.title = 'Test' content.description = 'Desc' form = EditForm(content, DummyRequest()) form.update() form.apply_changes(**{'title': 'Test2', 'description': 'Desc2'}) self.assertEqual(content.title, 'Test2') self.assertEqual(content.description, 'Desc2')
def test_editform_cancel(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() form = EditForm(content, DummyRequest( POST = {'form.buttons.cancel': 'Cancel'})) res = form.update() self.assertEqual(res.headers['location'], '.')
def test_editform_cancel(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() form = EditForm(content, DummyRequest(POST={'form.buttons.cancel': 'Cancel'})) res = form.update() self.assertEqual(res.headers['location'], '.')
def test_editform_save(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() content.title = 'Test' content.description = 'Desc' form = EditForm(content, DummyRequest( POST = {'title': 'Test2', 'description': 'Desc2', 'form.buttons.save': 'Save'})) res = form.update() self.assertEqual(res.headers['location'], '.') self.assertEqual(content.title, 'Test2') self.assertEqual(content.description, 'Desc2') self.assertIn('Changes have been saved.', ptah.view.render_messages(form.request))
def test_editform_save(self): from ptahcms.forms import EditForm ptah.auth_service.set_userid(ptah.SUPERUSER_URI) content = Content() content.title = 'Test' content.description = 'Desc' form = EditForm( content, DummyRequest( POST={ 'title': 'Test2', 'description': 'Desc2', 'form.buttons.save': 'Save' })) res = form.update() self.assertEqual(res.headers['location'], '.') self.assertEqual(content.title, 'Test2') self.assertEqual(content.description, 'Desc2') self.assertIn('Changes have been saved.', ptah.view.render_messages(form.request))