Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying FastAPI Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
FastAPI Cookbook

FastAPI Cookbook

By : Giunio De Luca
4.3 (4)
close
close
FastAPI Cookbook

FastAPI Cookbook

4.3 (4)
By: Giunio De Luca

Overview of this book

FastAPI is a cutting-edge Python framework that is revolutionizing the way web apps and APIs are built. Known for its speed, simplicity, and scalability, FastAPI empowers developers to create high-performing applications with ease. This book will help you leverage FastAPI’s immense potential to handle high-traffic scenarios and integrate seamlessly with modern Python tools. The book begins by familiarizing you with the basics of setting up and configuring your FastAPI environment before moving to the intricacies of building RESTful APIs, managing data with SQL and NoSQL databases, and handling authentication and authorization. Next, you'll focus on advanced topics such as custom middleware, WebSocket communication, and integration with various Python libraries. Each chapter is meticulously crafted with practical recipes, progressing from foundational concepts to advanced features and best practices. The concluding chapters show you how to optimize performance, implement rate limiting, and execute background tasks, empowering you to become a proficient FastAPI developer. By the end of this book, you'll have gained the skills you need to migrate existing apps to FastAPI, and be equipped to tackle any challenge in the modern web development landscape, ensuring your apps are not only functional, but also efficient, secure, and scalable.
Table of Contents (15 chapters)
close
close

Testing API Endpoints

Integration tests verify that different parts of your application work together as expected. They are crucial for ensuring that your system’s components interact correctly, especially when dealing with external services, databases, or other APIs.

In this recipe, we will test two endpoints that interact with an SQL database. One will add an item to the database, the other will read an item based on the ID.

Getting ready

To apply the recipe you need your testing environment already setup for pytest. If this is not the case check the recipe Setting up testing environments of the same chapter.

Also, the recipe will show you how to make integration tests with existing endpoints of the application. You can use it for your application or you can build the endpoints for our protoapp as follows.

If you are using the recipe to test your endpoint you can directly jump on the How to it… section and apply the rules to tour endpoints.

Otherwise...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY