Esempio n. 1
0
def make_post():
    comments = [make_comment() for _ in range(2)]
    author = make_author()
    return Post(id=fake.random_int(),
                title=fake.catch_phrase(),
                author=author,
                comments=comments)
Esempio n. 2
0
def make_post(with_comments=True, with_author=True):
    comments = [make_comment() for _ in range(2)] if with_comments else []
    author = make_author() if with_author else None
    return Post(id=fake.random_int(),
                title=fake.catch_phrase(),
                author=author,
                comments=comments)
Esempio n. 3
0
def make_post(with_comments=True, with_author=True, with_keywords=True):
    comments = [make_comment() for _ in range(2)] if with_comments else []
    keywords = [make_keyword() for _ in range(3)] if with_keywords else []
    author = make_author() if with_author else None
    return Post(
        id=fake.random_int(),
        title=fake.catch_phrase(),
        author=author,
        author_id=author.id if with_author else None,
        comments=comments,
        keywords=keywords,
    )