Exemplo n.º 1
0
    def test_model_list(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']

        res = ModelView.__renderer__(model, DummyRequest())
        self.assertIn('value="%s"'%rowid, res.body)

        res = ModelView.__renderer__(model, DummyRequest(
                params={'batch': 0}))
        self.assertIn('value="%s"'%rowid, res.body)

        res = ModelView.__renderer__(model, DummyRequest(
                params={'batch': 'unknown'}))
        self.assertIn('value="%s"'%rowid, res.body)
Exemplo n.º 2
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)
Exemplo n.º 3
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')
Exemplo n.º 4
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
Exemplo n.º 5
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])
Exemplo n.º 6
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))
Exemplo n.º 7
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