Skip to content

API for Managing test cases and their execution results across multiple test assets, with data stored in a SQLite database.

License

Notifications You must be signed in to change notification settings

john0isaac/flask-api-sqlite-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1c6b901 · Feb 29, 2024

History

11 Commits
Feb 28, 2024
Feb 27, 2024
Feb 27, 2024
Feb 29, 2024
Feb 28, 2024
Feb 28, 2024
Feb 28, 2024
Feb 27, 2024

Repository files navigation

flask-api-sqlite-db

API for Managing test cases and their execution results across multiple test assets, with data stored in a SQLite database.

Running the app

To run the Flask application, follow these steps:

  1. Download the project starter code locally

    git clone https://github.com/john0isaac/flask-api-sqlite-db.git
    cd flask-api-sqlite-db
  2. Install, initialize and activate a virtualenv using:

    pip install virtualenv
    python -m virtualenv venv
    source venv/bin/activate

    Note - In Windows, the venv does not have a bin directory. Therefore, you'd use the analogous command shown below:

    source venv\Scripts\activate
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Execute the following command in your terminal to start the flask app

    export DATABASE_FILENAME=testdb.db
    export FLASK_APP=src.app
    export FLASK_ENV=development
    flask run --reload

Run the tests

  1. Inside your virtual environment, execute the following command to run the tests

    python flask_test.py

API Documentation

Error handling

Invoking any of the following errors will return a JSON object in this format:

{
  "success": False,
  "error": 400,
  "message": "bad request"
}

The API will return these error types when the request fails:

  • 400: Bad Request
  • 405: Method Not Allowed
  • 422: Not Processable
  • 404: Resource Not Found

Endpoints

GET /tests

  • Sample
{
    "success": true,
    "test_cases": [
        {
            "description": "First Test Description",
            "id": 1,
            "name": "Updated Test Case"
        },
        {
            "description": null,
            "id": 2,
            "name": "Second Test"
        }
    ],
    "total_test_cases": 5
}

POST /tests

  • Sample
{
    "success": true,
    "test_case": {
        "description": "Fifth Test Case Description",
        "id": 6,
        "name": "Fifth Test Case"
    },
    "total_test_cases": 6
}

GET /tests/{test.id}

  • Sample
{
    "success": true,
    "test_case": {
        "description": "Fifth Test Case Description",
        "id": 6,
        "name": "Fifth Test Case"
    }
}

PATCH /tests/{test.id}

  • Sample
{
    "success": true,
    "test_case": {
        "description": "Sixth Test Case Description",
        "id": 6,
        "name": "Sixth Test Case"
    },
    "total_test_cases": 6
}

DELETE /tests

  • Sample
{
    "deleted_test_case_id": 6,
    "success": true,
    "total_test_cases": 5
}

GET /executions

  • Sample
{
    "asset": {
        "id": 2,
        "name": "Second Asset"
    },
    "executions": [
        {
            "details": "Success",
            "execution_date": "Sat, 02 Mar 2024 17:35:30 GMT",
            "id": 4,
            "status": true,
            "test_case": {
                "id": 1,
                "name": "Updated Test Case"
            }
        },
        {
            "details": "Success",
            "execution_date": "Sun, 03 Mar 2024 18:35:30 GMT",
            "id": 5,
            "status": true,
            "test_case": {
                "id": 3,
                "name": "Third Test"
            }
        }
    ],
    "success": true,
    "total_executions": 2
}

POST /executions

  • Sample
{
    "execution": {
        "asset_id": 1,
        "details": "Sucess",
        "id": 10,
        "status": true,
        "test_case_id": 1,
        "timestamp": "2024-02-29 09:36:57"
    },
    "success": true,
    "total_executions": 10
}

About

API for Managing test cases and their execution results across multiple test assets, with data stored in a SQLite database.

Resources

License

Stars

Watchers

Forks