Required components for building and running:
- Docker for managing applications
- Python Poetry for managing project specific dependencies and so much other goodness
- pyenv for managing local python installations
The API may read environment variables from the system, but also falls back on defaults:
Name | Default Value | Comment |
---|---|---|
INTERNAL_MONGO_CONNECTION_URL |
- | used for testcontainers |
MONGO_TECHNICAL_USER_USERNAME |
admin |
setup of technical user recommended (issue#2) |
MONGO_TECHNICAL_USER_PASSWORD |
admin |
setup of technical user recommended (issue#2) |
MONGO_HOST |
localhost |
|
MONGO_PORT |
27017 |
|
MONGO_COLLECTION |
content |
the collection the technical database user needs write access to |
MONGO_AUTH_SOURCE |
admin |
the authentication authority |
Run the database:
make docker-compose-up
Run the containerized HTTP endpoint:
make docker-build-development docker-run-and-attach
Once the container was build, running it by
make docker-run-and-attach
is totally sufficient.
An example cURL command like:
curl --request POST \
--url http://localhost:8000/periodictable/reactivenonmetals/hydrogen \
--header 'Content-Type: application/json' \
--data '{ "state":"gas", "weight": 1.008, "energy_levels": 1, "electronegativity":2.20 }'
should return anything like
{
"resource_path": "periodictable/reactivenonmetals/hydrogen1",
"electronegativity": 2.2,
"energy_levels": 1,
"metadata:created": "2021-06-14T18:38:03.933000",
"metadata:updated": "2021-06-14T18:38:03.933000",
"state": "gas",
"weight": 1.008
}
The response body will be indented.
# automatic path resolution has some issues:
# - https://github.com/floriansalihovic/post-anything/issues/4
export PYTHONPATH=src:$PYTHONPATH
poetry run pytest
Running them manually:
poetry run pre-commit