From 269c81b5a2a1997a91f5ebe5068c893bfb8ed8c7 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Tue, 17 Sep 2013 14:12:23 +0300 Subject: [PATCH] More tests added --- tests/batch_fetch/test_deep_relationships.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/batch_fetch/test_deep_relationships.py b/tests/batch_fetch/test_deep_relationships.py index a4b6737..afd39b4 100644 --- a/tests/batch_fetch/test_deep_relationships.py +++ b/tests/batch_fetch/test_deep_relationships.py @@ -61,8 +61,7 @@ class TestBatchFetchDeepRelationships(TestCase): self.Article = Article self.Tag = Tag - def setup_method(self, method): - TestCase.setup_method(self, method) + def init_data(self): articles = [ self.Article(name=u'Article 1'), self.Article(name=u'Article 2'), @@ -89,7 +88,22 @@ class TestBatchFetchDeepRelationships(TestCase): self.session.add(category2) self.session.commit() + def test_supports_empty_related_entities(self): + category = self.Category(name=u'Category #1') + self.session.add(category) + self.session.commit() + categories = self.session.query(self.Category).all() + batch_fetch( + categories, + 'articles', + 'articles.tags' + ) + query_count = self.connection.query_count + assert not categories[0].articles + assert self.connection.query_count == query_count + def test_deep_relationships(self): + self.init_data() categories = self.session.query(self.Category).all() batch_fetch( categories, @@ -103,6 +117,7 @@ class TestBatchFetchDeepRelationships(TestCase): assert self.connection.query_count == query_count def test_many_to_many_backref_population(self): + self.init_data() categories = self.session.query(self.Category).all() batch_fetch( categories,