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)
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')
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
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])
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))
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