This repository contains an implementation of a REST service that allows you to view the current salary and date of the next raise for each
The service is implemented using asynchronous database connections using SQLAlchemy and Asyncpg. Asynchronous pytest is also used to write tests. Registration and authorization is implemented using the fastapi_users
library.
-
Clone the repository:
git clone [email protected]:nnnLik/salary-viewer-service.git
-
Navigate to the project directory:
cd shift-ml-testtask
-
Create .env.db and env.server. You will find the variables in the .env.example file.
-
Run the service and database in Docker with Docker Compose:
docker-compose up --build
-
After a successful start, the service will be available at:
http://localhost:8888
Documentation on the service's API is available at:
http://localhost:8888/docs
You must register a user to access salary information and the date of the next raise. Send a POST
request to the /auth/jwt/register
endpoint with the following data in the body of the request:
{
"email": "[email protected]",
"password": "secret",
"is_active": true,
"is_superuser": false,
"is_verified": false
}
To create a position, send a POST
query to the /position/positions
endpoint. Pass the following data in the body of the request:
{
"id": 1,
"name": "front end developer",
"base_salary": 600
}
After successful registration, fill in the user information by sending a POST
query to endpoint /employee/info
. In the header of the request specify the authorization token:
Authorization: Bearer <token>
Pass the following data in the body of the request:
{
"first_name": "Big",
"last_name": "Dude",
"birth_year": 1900,
"position_id": 1
}
To get salary information and the date of the next raise, send a GET
query to the /employee/salary
endpoint. Specify the authorization token in the header of the request:
Authorization: Bearer <token>
In response you will get the following:
{
"id": int,
"first_name": str,
"last_name": str,
"birth_year": int,
"employment_date": str,
"position": str,
"employee_id": str,
"salary": int,
"next_increase_date": str,
"days_until_increase": int.
}
- To run the test you will need to install all the dependencies:
poetry install
- To run the Tests:
pytest -vv tests/
- Data fixtures
- Admin