Both exercises involve implementing code and then verifying that the written test cases pass as expected.
All tests are located in test_backend_engineer_interview.py
backend-engineer-interview/
backend_engineer_interview/
app.py
handlers.py - Routes should be implemented here
models.py - Database models, new models should be added here
tests/
test_backend_engineer_interview.py - Test cases for the exercises
app.db - initialized sqlite db
openapi.yaml - Open API specifications
Pair programming task (candidate drives) where the goal is to implement a function that splits a start and end date around a specified split date.
Implement handlers.split_start_end_dates
. Use the test cases in TestSplitDates
to verify your work. The exercise is complete when they all pass.
Exercise is meant to be completed asynchronously and then brought to the follow up interview. The exercise can be completed using any IDE, but this repo includes settings for VSCode.
The overall structure of the API has routes defined in openapi.yaml
which are then wired to python functions with operationId
. For an example,
look at the provided /v1/status
endpoint.
- Install [email protected]. This can be managed with asdf and asdf-python
- Install poetry
- Run
poetry config virtualenvs.in-project true
- Run
poetry install --no-root
. Installing the dependencies will take a few minutes. - Run
poetry run python -m backend_engineer_interview
to bring up the API server
- Complete the
get_employee
endpoint inhandlers.py
. The table model and response model already exist. To verify that it's working as expected, all of theTestGetEmployee
tests should pass. - Implement the
patch_employee
. To verify that it's working as expected, all of theTestPatchEmployee
tests should pass. - Implement the
post_application
API definition and implement the handler. To verify that it's working, all of theTestPostApplication
tests shuold pass.
-
How do I reset the database?
Delete the app.db file and run
poetry run alembic upgrade head
-
What URL are the docs at?
-
How do I see an example response?
If you would like to see the example response generated from the open API definition. Simply comment out
operationId
. -
How do I create new tables from models?
New tables can be generated by running
poetry run alembic revision --autogenerate -m "Revision name"
and thenpoetry run alembic upgrade head