A basic backend service for a simple library app to be used for learning RestApi automation testing
- python 3.9.5 - https://www.python.org/downloads/release/python-395/
- pip - https://www.liquidweb.com/kb/install-pip-windows/
- clone the repository
- install requirements: pip install -r requirements.txt
- run the back_end.py file: python back_end.py
- do requests to http://127.0.0.1:50000
- remove/delete the db.sqlite file
- run the back_end.py script again - it will recreate the database and init some test data
- the app exposes endpoints for users, books, reservations
- get all users: Get /users
- create user: Post /users
- get user: Get /users/<user_id>
- delete user: Delete /users/<user_id>
- edit user: Put /users/<user_id>
{
"id": "",
"first_name": "",
"last_name": "",
"email": ""
}
- email should be unique
- get all books: Get /books
- create book: Post /books
- get book: Get /books/<book_id>
- delete book: Delete /books/<book_id>
- edit book: Put /books/<book_id>
{
"id": "",
"name": "",
"author": ""
}
- get all reservations: Get /reservations
- create reservation: Post /reservations
- get reservation by book_id: Get /reservations/book/<book_id>
- get reservation by user_id: Get /reservations/user/<user_id>
- get reservation by user_id and book_id: Get /reservations/user/<user_id>/book/<book_id>
- delete reservation: Delete /reservations/user/<user_id>/book/<book_id>
- delete reservation by book_id: Delete /reservations/book/<book_id>
- delete reservation by user_id: Delete /reservations/user/<user_id>
- edit reservation: Put /reservations/user/<user_id>/book/<book_id>
{
"book_id":"",
"user_id":"",
"reservation_date": "",
"reservation_expiration_date": ""
}
{
"user": {
"id": "",
"first_name": "",
"last_name": "",
"email": ""
},
"book": {
"id": "",
"name": "",
"author": ""
},
"reservation_date": "",
"reservation_expiration_date": ""
}