def test_get_recent_comments(): PostFactory.create_batch(10, published=True) for post in Post.objects.all(): CommentFactory.create_batch(3, post=post) # Generate 30 comments in system, but request back only n through the template tag. recent = get_recent_comments(10) assert len(recent['comments']) == 10 recent = get_recent_comments(7) assert len(recent['comments']) == 7 # Check object type of first element in return list assert isinstance(recent['comments'][0], Comment)
def cats_and_posts(): ConfigFactory() CategoryFactory.create_batch(10) PostFactory.create_batch(30)
def posts_with_comments(): PostFactory.create_batch(3) for p in Post.objects.all(): CommentFactory(post=p)
def cats_and_posts(): PostFactory.create_batch(30)