Ejemplo 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)