Beispiel #1
0
    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.users = [self.User(), self.User()]
        self.articles = [
            self.Article(),
            self.Article(),
            self.Article(),
            self.Article()
        ]
        self.posts = [
            self.BlogPost(),
            self.BlogPost(),
            self.BlogPost(),
        ]

        self.session.add_all(self.users)
        self.session.add_all(self.articles)
        self.session.add_all(self.posts)
        self.session.commit()

        self.chain = QueryChain([
            self.session.query(self.User).order_by('id'),
            self.session.query(self.Article).order_by('id'),
            self.session.query(self.BlogPost).order_by('id')
        ])
def chain(session, users, articles, posts, User, Article, BlogPost):
    return QueryChain(
        [
            session.query(User).order_by('id'),
            session.query(Article).order_by('id'),
            session.query(BlogPost).order_by('id')
        ]
    )