Exemplo n.º 1
0
    def setup_method(self, method):
        self.f = NamedTemporaryFile()
        uri = 'sqlite:///' + self.f.name
        app.config['DATABASE'] = uri
        app.config['TESTING'] = True

        self.client = app.test_client()
        self.ctx = app.test_request_context()
        self.ctx.push()

        initdb()

        fixtures = [(Page, dict(title='test', content='no content')),
                    (Page, dict(title='to rename', content='blah')),
                    (Page, dict(title='to delete', content='blah')),
                    (Page, dict(title='search target', content='abc123def')),
                    (Page, dict(title=u'테스트', content=u'한글')),
                    (Page, dict(title='orphan', content='blah')),
                    # link test
                    (Page, dict(title='link_source', content='blah')),
                    (Link, dict(source='link_source', target='link_target1')),
                    (Link, dict(source='link_source', target='link_target2'))]

        session = Session()
        with session.begin():
            for table, fixture in fixtures:
                t = table(**fixture)
                session.merge(t)
Exemplo n.º 2
0
    def test_delete_page(self):
        res = self.get('delete_page', title='to delete')
        assert res.status_code == HTTP_OK

        session = Session()
        before = session.query(Page).count()
        res = self.post('delete_page', title='to delete')
        self.redirect(res, 'home')
        after = session.query(Page).count()
        assert not Page.load('to delete')
        assert before-1 == after