dimanche 29 novembre 2020

best way for UnitTest a flask application

im trying to do a simple unit-test for testing the functionality of the application. The unit-test should create a mock JSON database file (users.json) with predefined data, and validate that the application returns the correct information.

For example, given the following input file:

**

{
    "test_user": {
        "id": "test",
        "name": "Test User",
        "favorite_color": "Black"
    }
}

** (Test #1) Accessing the /users URI should return:

**

{
    "test_user": {
        "name": "Test User",
        "favorite_color": "Black"
    }
}

** (Test #2) Accessing the /user/test_user URI should return:

**

{
    "test_user": {
        "id": "test",
        "name": "Test User",
        "favorite_color": "Black"
    }
}

** (Test #3) Accessing the /user/test_user123 URI should return HTTP code 404 as the user does not exist in the database.

what is the right way to do so?

Aucun commentaire:

Enregistrer un commentaire