Beispiel #1
0
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)
Beispiel #2
0
def cats_and_posts():
    ConfigFactory()

    CategoryFactory.create_batch(10)
    PostFactory.create_batch(30)
Beispiel #3
0
def posts_with_comments():
    PostFactory.create_batch(3)
    for p in Post.objects.all():
        CommentFactory(post=p)
Beispiel #4
0
def cats_and_posts():
    PostFactory.create_batch(30)