Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

LandRegistry/digital-street-lender-management-api

Repository files navigation

HM Land Registry Digital Street Proof of Concept - Lender Management API

Available routes

Route What it does
GET /health Returns some basic information about the app (JSON)
GET /health/cascade/<depth> Returns the app's health information as above but also the health information of any database and HTTP dependencies, down to the specified depth (JSON)
GET /users Returns a list of users in the conveyancer's management system (JSON)
POST /users Creates a new user in the conveyancer's management system (JSON)
GET /users/<identity> Returns a user with the specified id. (JSON)
PUT /users/<identity> Modifies a user with the specified id. (JSON)

Quick start

Docker

This app supports the Land Registry common development environment so adding the following to your dev-env config file is enough:

  lender-management-api:
    repo: https://github.com/LandRegistry/digital-street-lender-management-api.git
    branch: master

The Docker image it creates (and runs) will install all necessary requirements and set all environment variables for you.

Standalone

Environment variables to set

  • PYTHONUNBUFFERED (suggested value: yes)

  • PORT

  • LOG_LEVEL

  • COMMIT

  • APP_NAME

  • MAX_HEALTH_CASCADE

  • DEFAULT_TIMEOUT (suggested value: 30)

    (The default timeout is applied to all calls which go via g.requests but can be overriden on a case by case basis with the standard timeout argument)

When not using gunicorn
  • FLASK_APP (suggested value: user_api/main.py)
  • FLASK_DEBUG (suggested value: 1)

Running (when not using gunicorn)

(The third party libraries are defined in requirements.txt and can be installed using pip)

python3 -m flask run
or
flask run
or
make run

Testing

Unit tests

The unit tests are contained in the unit_tests folder. Pytest is used for unit testing. To run the tests use the following command:

make unittest
(or just py.test)

To run them and output a coverage report and a junit xml file run:

make report="true" unittest

These files get added to a test-output folder. The test-output folder is created if doesn't exist.

You can run these commands in the app's running container via docker-compose exec lender-management-api <command> or exec lender-management-api <command>. There is also an alias: unit-test lender-management-api and unit-test lender-management-api -r will run tests and generate reports respectively.

Integration tests

The integration tests are contained in the integration_tests folder. Pytest is used for integration testing. To run the tests and output a junit xml use the following command:

make integrationtest
(or py.test integration_tests)

This file gets added to the test-output folder. The test-output folder is created if doesn't exist.

To run the integration tests if you are using the common dev-env you can run docker-compose exec lender-management-api make integrationtest or, using the alias, integration-test lender-management-api.