airplanes

Aircraft Passenger Capacity Consumption API

Environment Variables

The following environment variables are required to run the app.

  • DEV_SECRET_KEY
  • DATABASE_URL

Running the app

  1. Clone the repo.

    git clone git@github.com:sitati-elsis/airplanes.git
  2. cd into the repo you have just cloned.

    cd airplanes/
  3. Create a virtual environment and activate it.

  4. Inside the virtual environment, install app dependencies.

    pip install -r requirements.txt
  5. Run Migrations

    python manage.py migrate
  6. Start the app.

    python manage.py runserver

Using the app

  1. To create a plane, use the POST method on /api/planes/ endpoint and supply the id and passenger field values in the request body.
    curl -X POST http://localhost:8000/api/planes/ -H "Content-Type: application/json" -d '{"id": 1234, "passengers": 5678}'
    
    # response
    {"id":1234,"passengers":5678}
  2. To view total_airplane_fuel_consumption_per_minute and maximum_minutes_able_to_fly information, send a GET request on /api/planes/ endpoint.
    curl -X GET http://localhost:8000/api/planes/
    
    # response
    {
        "total_airplane_fuel_consumption_per_minute":13.829052127757778,
        "maximum_minutes_able_to_fly":17846.487070839885,
        "planes":[
            {
                "id":1234,
                "litres":200,
                "passengers":5678,
                "fuel_tank_capacity":246800,
                "plane_fuel_comsumption":2.4730521277577786,
                "passenger_consumption":11.356,
                "total_fuel_consumption":13.829052127757778
            }
        ]
    }

API documentation

Interactive API documentation can be accessed through http://localhost:8000/api/docs/.

Running mypy

mypy can be run to perform static checks on the code. To perform this check, run the following command;

mypy -p api

Tests and Test Coverage

Tests can be run using the following command.

coverage run manage.py test

To view the coverage report, use the command below.

coverage report -m

Assumptions / Additional notes