Welcome to the eLearning API project! This guide will help you set up and run the project on your local machine.
Before you begin, ensure you have the following installed:
Once cloned, cd into the repository. All commands to run in the next steps will be inside this directory.
git clone https://github.com/jnous-5/elearning-api.git
cd elearning-apiInside VSCode, click Reopen in Container when prompted. If there's no prompt, manually open by hitting ⌘ + ⇧ + P (Command + Shift + P) and select Dev Containers: Reopen in Container command.
code .Duplicate the env file template and replace its configuration values to match your setup.
cp .env.example .envA postCreateCommand is configured from the dev container to automatically install dependencies once the container is created. If the script fails, you can manually install the dependencies by running the command below.
poetry installpython manage.py migrateIf you want to login to django's admin interface, run the following command and follow along the prompt.
python manage.py createsuperuserStart django's dev server.
python manage.py runserverBase API endpoint: http://127.0.0.1:8000/api
Django admin interface: http://127.0.0.1:8000/admin
There are 2 types of testing currently present in the app: unit and integration tests. Unit tests reside in the tests/unit directory while integration tests reside in tests/integration.
To run the tests (both unit and integration), run the following command.
python manage.py test # or python manage.py test --shuffleTo generate code coverage, first run the tests using the following command.
coverage run manage.py testThen generate the html report. The report can be found in htmlcov/index.html.
coverage htmlThe app uses poetry for managing dependencies. Make sure when running python you are inside the virtual env created by poetry. If you're using VSCode, normally this should be done automatically for you via the python.defaultInterpreterPath setting found in .vscode/settings.json file.
There are cases wherein opening the terminal in VSCode for the first time doesn't pick up this setting. If that's the case, simply open a new terminal session.
If it still doesn't work, you can always manually activate the poetry shell by running the command:
poetry shellVerify by checking the installed python path. It should point to /workspaces/elearning-api/.venv/bin/python. This is where python is installed in the container.
which pythonSuperuser account
Credentials
Email:admin@example.comPassword:
admin12345