예제 #1
0
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_basics(self):
        from ptah.cms.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
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_cancel(self):
        from ptah.cms.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'], '.')
예제 #3
0
    def test_editform_save_errors(self):
        from ptah.cms.forms import EditForm
        ptah.authService.set_userid(ptah.SUPERUSER_URI)

        content = Content()

        form = EditForm(content, DummyRequest(
            POST = {'form.buttons.save': 'Save'}))

        form.update()
        self.assertIn('Please fix indicated errors.',
                      form.request.session['msgservice'][0])
예제 #4
0
    def test_editform_cancel(self):
        from ptah.cms.forms import EditForm
        ptah.authService.set_userid(ptah.SUPERUSER_URI)

        content = Content()

        form = EditForm(content, DummyRequest(
            POST = {'form.buttons.cancel': 'Cancel'}))

        try:
            form.update()
        except Exception, res:
            pass
예제 #5
0
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_form_content(self):
        from ptah.cms.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
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_apply_changes(self):
        from ptah.cms.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')
예제 #7
0
    def test_editform_save(self):
        from ptah.cms.forms import EditForm
        ptah.authService.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'}))

        try:
            form.update()
        except Exception, res:
            pass
예제 #8
0
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_save(self):
        from ptah.cms.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))
예제 #9
0
파일: test_forms.py 프로젝트: runyaga/ptah
    def test_editform_apply_changes(self):
        from ptah.cms.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')