예제 #1
0
def test_get_all_books(client, db, all_headers, book_factory):
    books_url = url_for("api.all_books")
    resp = client.get(books_url, headers=all_headers["no_auth_headers"])
    assert resp.status_code == 200
    assert resp.json["total"] == 0

    default_num_books = 10
    books = book_factory.create_batch(default_num_books)
    save_all_to_db(db, books)

    resp = client.get(books_url, headers=all_headers["no_auth_headers"])
    assert resp.status_code == 200
    assert resp.json["total"] == default_num_books
예제 #2
0
def _items_data_min_days(db, book_factory):
    books = book_factory.create_batch(NUM_BOOKS)
    books[0].genre = "Fiction"
    books[1].genre = "Regular"
    books[2].genre = "Novel"
    save_all_to_db(db, books)
    items = [
        {"book_id": books[0].id,
         "due_at": datetime.now(pytz.utc) + timedelta(days=1)},
        {"book_id": books[1].id,
         "due_at": datetime.now(pytz.utc) + timedelta(days=1)},
        {"book_id": books[2].id,
         "due_at": datetime.now(pytz.utc) + timedelta(days=1)}]
    return items