Run the Project
- Create a python virtual environment using
venv
module.$ python39 -m venv <env name>
- Activate the virtual env.
- Clone the repository.
$ git clone https://github.com/kBashar/lemonhive_test.git
- Install dependencies.
$ pip install -r requirements.txt
5.Run the development Server
To run the development server from project root directory (lemonhive_test)
- set environment variable
FLASK_APP
tosrc.app:app
- Windows:
set FLASK_APP=src.app:app
- Unix:
export FLASK_APP=src.app:app
Endpoints
/config [GET]
returns a json formated data blob. This endpoint returns status 404 if there is no storage found.
{
"message": "No data Found"
}
/config [POST]
Accepts json data. json schema is as follows:
{
"firstName": str,
"secondName": str,
"ageInYears": int,
"address": str,
"creditScore": float
}
If valid a success message is sent back.
{
"message": "success"
}
If POSTed data is invalid the endpoint will return error status 400.
{
"message":"Data format Invalid"
}
Run tests
To run tests inside the root directory simplyrun
$ pytest
Schema Verification
We use jsonschema
library for json data validation.
Upon getting a POST request in /config
route, data is validated in
validate_data
function. This function depends on jsonchema
library to
validate a json data input.
If the data is invalid the library raises a ValidationError
exception. And the function
returns False
. Else if there is no error the function return True
.