Ejemplo n.º 1
0
    def test_model_add(self):
        from ptah.manage.model import ModelModule, ModelView

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(
                POST=MultiDict({'form.buttons.add': 'Add'})))
        form.csrf = False
        try:
            form.update()
        except Exception, res:
            pass
Ejemplo n.º 2
0
    def test_model_remove_errors(self):
        from ptah.manage.model import ModelModule, ModelView

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(
                POST=MultiDict({'form.buttons.remove': 'Remove'})))
        form.csrf = False
        form.update()

        self.assertIn("Please select records for removing.",
                      form.request.session['msgservice'][0])
Ejemplo n.º 3
0
    def test_model_remove_errors(self):
        from ptah.manage.model import ModelModule, ModelView

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(
                POST=MultiDict([('form.buttons.remove', 'Remove')])))
        form.csrf = False
        form.update()

        self.assertIn("Please select records for removing.",
                      ptah.view.render_messages(form.request))
Ejemplo n.º 4
0
    def test_model_remove(self):
        from ptah.manage.model import ModelModule, ModelView

        content = Content1()
        content.title = 'Content test'

        ptah.cms.Session.add(content)
        ptah.cms.Session.flush()

        rowid = content.__id__
        transaction.commit()

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(
                POST=MultiDict(
                    list({'rowid':rowid,
                          'form.buttons.remove': 'Remove'}.items()))))
        form.csrf = False
        res = form.update()

        self.assertIsInstance(res, HTTPFound)

        transaction.commit()

        rec = ptah.cms.Session.query(Content1).filter(
            Content1.__id__ == rowid).first()
        self.assertIsNone(rec)
Ejemplo n.º 5
0
    def test_model_add(self):
        from ptah.manage.model import ModelModule, ModelView

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(POST={'form.buttons.add': 'Add'}))
        form.csrf = False
        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], 'add.html')
Ejemplo n.º 6
0
    def test_model_remove(self):
        from ptah.manage.model import ModelModule, ModelView

        content = Content1()
        content.title = u'Content test'

        ptah.cms.Session.add(content)
        ptah.cms.Session.flush()

        rowid = content.__id__
        transaction.commit()

        mod = ModelModule(None, DummyRequest())
        model = mod['content1']

        form = ModelView(
            model, DummyRequest(
                POST=MultiDict({'rowid':rowid,
                                'form.buttons.remove': 'Remove'})))
        form.csrf = False
        try:
            form.update()
        except Exception, res:
            pass