示例#1
0
def test_create_post_should_be_successful(with_factories: None,
                                          pg_session: Session) -> None:
    PostFactory.create_batch(5)

    query = get_create_mutation("title", "content")
    context = {"session": pg_session}
    result = schema.execute(query, context=context)

    assert not result.errors
    assert result.data
    assert result.data["createPost"]["post"]
示例#2
0
def test_list_posts_should_be_successful(
    with_factories: None, pg_session: Session
) -> None:
    PostFactory.create_batch(5)

    query = "{posts {id title}}"
    context = {"session": pg_session}
    result = schema.execute(query, context=context)

    assert not result.errors
    assert len(result.data["posts"]) == 5
示例#3
0
def test_get_post_list(pg_session: Session, with_factories: None) -> None:

    PostFactory.create_batch(BATCH_CREATE)
    posts = PostService(pg_session).get_list()

    assert len(posts) == BATCH_CREATE