Sobes.tech
Junior — Middle

Have you conducted testing of integration scenarios in your projects?

sobes.tech AI

Answer from AI

Yes, in my projects I have conducted testing of integration scenarios. Integration tests verify the interaction between multiple components of a system, which helps identify errors that are not visible during unit testing.

For example, in Python, using pytest and requests, you can test API services by checking the correctness of several related parts of the application.

A simple example of an integration test:

import requests

def test_user_creation_and_fetch():
    # Create a user via API
    response = requests.post('http://localhost:5000/users', json={'name': 'Ivan'})
    assert response.status_code == 201
    user_id = response.json()['id']

    # Fetch the user by ID
    response = requests.get(f'http://localhost:5000/users/{user_id}')
    assert response.status_code == 200
    assert response.json()['name'] == 'Ivan'

This test checks that creating and retrieving a user work correctly together.