Skip to content

geoadmin/service-control

Repository files navigation

service-control

Branch Status
develop Build Status
master Build Status

Table of Content

Summary of the project

service-control provides and manages the verified permissions. TBC

Local development

Dependencies

Prerequisites on host for development and build:

  • python version 3.12
  • pipenv
  • docker and docker compose

Setup

Copy the .env.dist file to .env on your local machine:

cp .env.dist .env

Initialize the local python environment with pipenv:

pipenv sync -d

and start the local postgres container

docker compose up

Local Development

vs code Integration

There are some possibilities to debug this codebase from within visual studio code.

Debug from vs code

In order to debug the service from within vs code, you need to create a launch-configuration. Create a folder .vscode in the root folder if it doesn't exist and put a file launch.json with this content in it:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python Debugger: Attach",
      "type": "debugpy",
      "request": "attach",
      "justMyCode": false,
      "connect": {
        "host": "localhost",
        "port": 5678
      }
    }
  ]
}

Now you can start the server with make serve-debug. The bootup will wait with the execution until the debugger is attached, which can most easily done by hitting f5.

Attach debugger to the tests

The same process described above can be used to debug tests. Simply run make test-debug, they will then wait until the debugger is attached.

Run tests from within vs code

The unit tests can also be invoked inside vs code directly. To do this you need to have following settings locally to your workspace:

  "python.testing.pytestArgs": [
    "app"
  ],
  "python.testing.unittestEnabled": false,
  "python.testing.pytestEnabled": true,
  "python.testing.debugPort": 5678

They can either be in .vscode/settings.json or in your workspace settings. Now the tests can be run and debugged with the testing tab of vscode (beaker icon).

Type Checking

Mypy

Type checking can be done by either calling mypy or the make target:

make type-check

This will check all files in the repository.

Library types

For type-checking, the external library mypy is being used. See the type hints cheat sheet for help on getting the types right.

Some 3rd party libraries need to have explicit type stubs installed for the type checker to work. Some of them can be found in typeshed. Sometimes dedicated packages exist, as is the case with django-stubs.

If there aren't any type hints available, they can also be auto-generated with stubgen