def test_model_remove(self): from ptahcms.manage.model import ModelModule, ModelView content = Content1() content.title = 'Content test' Session = ptah.get_session() Session.add(content) 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() Session = ptah.get_session() rec = Session.query(Content1).filter(Content1.__id__ == rowid).first() self.assertIsNone(rec)
def test_model_remove(self): from ptahcms.manage.model import ModelModule, ModelView content = Content1() content.title = 'Content test' Session = ptah.get_session() Session.add(content) 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() Session = ptah.get_session() rec = Session.query(Content1).filter( Content1.__id__ == rowid).first() self.assertIsNone(rec)
def test_model_add(self): from ptahcms.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 ptahcms.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_remove_errors(self): from ptahcms.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_errors(self): from ptahcms.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))