This repository contains a coding test for Python candidates.
mock_server/: Contains the Flask server that provides paginated employee data.task/: This is where the candidate should implement their solution.
-
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt pip install requests # Candidate will need this
In one terminal:
python mock_server/server.pyThe server runs on http://127.0.0.1:5001.
The candidate should implement the EmployeeAnalysis class in task/solution.py with the following methods:
get_employee_count(): Returns the total number of employees.get_average_salary_by_department(): Calculates the average salary for each department.get_top_3_highest_paid_employees(): Finds the top 3 employees with the highest salary.
Objective:
The class is initialized with a base_url. Use this URL to download all employee records (which is paginated) and implement the analysis logic.
To validate the solution, run the following command in the terminal (ensure the mock server is NOT running, as the test suite handles its lifecycle):
pytest tests/test_solution.py