示例#1
0
    def test_model_add_back(self):
        from ptah.manage.model import ModelModule, AddRecord

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

        form = AddRecord(
            model, DummyRequest(POST={'form.buttons.back': 'Back'}))
        form.csrf = False
        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')
示例#2
0
    def test_model_add_errors(self):
        from ptah.manage.model import ModelModule, AddRecord

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

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

        self.assertIn("Please fix indicated errors.",
                      ptah.view.render_messages(form.request))
示例#3
0
    def test_model_add_back(self):
        from ptah.manage.model import ModelModule, AddRecord

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

        form = AddRecord(
            model, DummyRequest(
                POST=MultiDict({'form.buttons.back': 'Back'})))
        form.csrf = False
        try:
            form.update()
        except Exception, res:
            pass
示例#4
0
    def test_model_add_errors(self):
        from ptah.manage.model import ModelModule, AddRecord

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

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

        self.assertIn("Please fix indicated errors.",
                      form.request.session['msgservice'][0])
示例#5
0
    def test_model_add_node(self):
        from ptah.manage.model import ModelModule, AddRecord

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

        form = AddRecord(
            model, DummyRequest(
                POST=MultiDict({'title': u'Test content',
                                'form.buttons.add': 'Add'})))
        form.csrf = False
        try:
            form.update()
        except Exception, res:
            pass
示例#6
0
    def test_model_add_node(self):
        from ptah.manage.model import ModelModule, AddRecord

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

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

        id = form.record.__id__
        transaction.commit()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], './%s/'%id)
        self.assertEqual(len(ptah.cms.Session.query(self.Content2).all()), 1)

        content = ptah.cms.Session.query(self.Content2) \
            .filter(self.Content2.__id__ == id).first()
        self.assertEqual(content.title, 'Test content')