예제 #1
0
파일: test_model.py 프로젝트: WouterVH/ptah
    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)
예제 #2
0
파일: test_model.py 프로젝트: runyaga/ptah
    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)
예제 #3
0
파일: test_model.py 프로젝트: runyaga/ptah
    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')
예제 #4
0
파일: test_model.py 프로젝트: WouterVH/ptah
    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
예제 #5
0
파일: test_model.py 프로젝트: WouterVH/ptah
    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])
예제 #6
0
파일: test_model.py 프로젝트: runyaga/ptah
    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))
예제 #7
0
파일: test_model.py 프로젝트: WouterVH/ptah
    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