A short glance at software testing

As computer applications tend to be delegated even more human decisions, the software engineering industry has acknowledged testing as an essential part of the development process.

Approaches to software testing vary. Applications are tested as a whole, or as integrated systems, or even unit by unit. We have test engineers, test managers, and testers. There are platforms that offer outsourcing manual testing, and there are automated tests: literally, applications operating other applications and often even imitate a living user.

Why test an API?

The case study is about testing the API calls performance. Python asyncio and concurrent.futures packages are used to run multiple API calls. They divide the loop runs into pools and go through several pools in a parallel manner, thus, performing more than one call simultaneously. This reduces the total execution time.

The question of an optimal number of threads arose in the following regard. Let’s imagine there is a mobile app that accesses an open-source database that provides an API. I needed to write an API call that successfully retrieves the data and integrate it into the app. This integration ought to include a first processing of the received data.

As I will show in the next section, during the initial approach to the data, I met a few problems. The data could only be downloaded in small pieces, thus, forcing me to make multiple requests. This could slow down the app performance and spoil the user experience.

The fact made me look closer at the API call itself, despite, originally, my major task was to build a data pipeline inside the app.

I, therefore, started to experiment with the API call.

The experiment aimed to find out an optimal number of threads, or the maximum number of parallel calls. This number has its limits that depend on different factors.

After I had gone through some painful mistakes, I managed to stick to an ad hoc systematic approach that I am going to disclose. The article shows the steps towards a complete testing code, which is attached at the end of it.

#automated-testing #software-testing #data-science #python #api-testing

Testing a Python-based API call with a data science charm
1.35 GEEK