Testing asynchronous applications with FastAPI and pytest
Part of the Our Connected Universe specialist track
Let's discuss testing of
FastAPI asynchronous applications. The talk will cover different types of testing mechanisms i.e. unit testing and end-to-end testing using
pytest. I will also present some interesting test scenarios from
kernelCI-API which is a new backend being developed for
KernelCI - a distributed testing system for Linux kernel.
See this talk and many more by getting your ticket to PyCon AU now!I want a ticket!
Calling out all passionate python programmers (and testers of course), even if you have a basic understanding of python syntax and concepts, you are more than welcome to attend this talk. This talk will be helpful to all Pythonistas who are interested to know how to test asynchronous applications with
FastAPI is a modern python framework for building RESTful APIs. The talk will begin with a brief introduction to FastAPI and asynchronous programming with it.
Since real world projects and examples always help better to understand technologies and concepts, I'll take
KernelCI as a reference point for the presentation.
For further context,
KernelCI (https://kernelci.org/) is a test system for upstream Linux Kernel.
KernelCI-API (source code can be found at https://github.com/kernelci/kernelci-api) is a new backend for
KernelCI. Since it is written with FastAPI, I will explain the API designs and tests using it.
Starting with some simple testing examples from the KernelCI API such as CRUD operations, I will progress towards more advanced test cases including authentication and pub/sub mechanism. For end-to-end tests, I will go through how to write a test pipeline that includes APIs that asynchronously wait for certain operations to take place e.g. listening on a specific channel for messages. In addition to that, the talk will cover some pytest features for managing order and dependencies between tests.
In the end, I will discuss how to use different testing environments for automating tests.
Jeny Sadadia is a Software Engineer at Collabora, previously at eInfochips(an arrow company) and an Outreachy alumni of December 2021 cohort. She is an open source enthusiast and actively involved with KernelCI project for a while. Other than programming, she is also passionate about dancing.