Service for handling backend calls in LITE.
-
Download the repository:
git clone https://github.com/uktrade/lite-api.git
cd lite-api
-
First time setup
-
Set up your local config file:
cp local.env .env
- you will want to set this up with valid values, ask another developer or get them from Vault. If you want to run in Docker then uncomment the appropriate line in.env
refering to DATABASE_URL
-
Initialise submodules
git submodule init
git submodule update
-
Ensure docker is running
-
Build and start docker images:
docker network create lite
- shared network to allow API and frontend to communicatedocker-compose build
- build the container imagedocker-compose start db
- to bring up the db to allow the migrate to succeed
-
Run the migrations
./bin/migrate.sh
- Perform the Django migrations
-
-
Starting the service
docker-compose up
- to start the API's django server
-
Go to the index page (e.g.
http://localhost:8100
) -
At this point you might want to seed your database with some static
- run
docker-compose run ./manage.py seedall
- run
Run the following command to add new users:
INTERNAL_USERS='[{"email"=>"foo@bar.gov.uk"}]' ./manage.py seedinternalusers
EXPORTER_USERS='[{"email"=>"foo@bar.com"}]' ./manage.py seedexporterusers
pipenv run ./manage.py process_tasks
will run all background tasks
To produce PDF documents you will also need to install WeasyPrint. Do this after installing the python packages in the Pipfile;
MacOS: https://weasyprint.readthedocs.io/en/stable/install.html#macos
Linux: https://weasyprint.readthedocs.io/en/stable/install.html#debian-ubuntu
To digitally sign documents endsesive
requires the OS library swig to be installed.
To install run sudo apt-get install swig
A p12 file is also required. Please see https://uktrade.atlassian.net/wiki/spaces/ILT/pages/1390870733/PDF+Document+Signing
API Docs available on GitHub Pages
Running locally without Docker
ER Diagrams can be viewed in docs/entity-relation-diagrams/.
To regenerate the diagrams run pipenv run ./manage.py create_er_diagrams
pipenv run ./manage.py test
will run all testspipenv run ./manage.py test cases
will run thecases
module tests
pipenv run ./manage.py coverage <module_to_run_coverage_on> <tests_to_run>
- Providing no positional arguments implies that you want to run all tests and collect the coverage:
pipenv run ./manage.py coverage
- The first positional argument implies what module you want to collect coverage for:
pipenv run ./manage.py coverage cases
will collect coverage on thecases
module and run only thecases
tests
- The second positional argument implies what tests to run in order to collect coverage for the given module:
pipenv run ./manage.py coverage cases all
will collect coverage on thecases
module and run all testspipenv run ./manage.py coverage cases queues
will collect coverage on thecases
module and only run thequeues
tests
lite-api - Service for handling backend calls in LITE.
lite-frontend - The web frontend for LITE.
pipenv run bandit -r .
pipenv run ./manage.py test
with option --parallel
to run them in parallel
To run a specific folder:
pipenv run ./manage.py test <folder_name>