示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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))
示例#4
0
    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))
示例#5
0
    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')
示例#6
0
    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')
示例#7
0
    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')
示例#8
0
    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')
示例#9
0
    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'], '.')
示例#10
0
    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'], '.')
示例#11
0
    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))
示例#12
0
    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))