# metadata-consistency

The purpose of this project is to keep content metadata consistent between MySQL art_relations and Neo4j music-graph.

## Setup

* Install [docker](https://docs.docker.com/get-docker/)
* Clone this repository
* Navigate to the lambda you want to work on in `lambda/`

## Running

### Start Container

```sh
docker compose up --build -d function
```

### Execute Function

Use the HTTP client of your choice. The body of the request is the `event` passed into the function.

```sh
curl --request POST \
  --url http://localhost:9000/2015-03-31/functions/function/invocations \
  --header 'Content-Type: application/json' \
  --data $(cat tests/sample_event.json)
```

### Load Changes

The `src` directory and `config.py` are mounted into the container via the `docker-compose.yaml` configuration. This means you don't need to re-build the entire container to see changes. **However** the container will need to be restarted. This process should be as quick as restarting uwsgi when making changes to a web application.

```sh
docker compose restart function
```

:zap: You should add this command to a post-write hook in your preferred editor to automatically restart.

## Linting and Testing

### Run Container

```sh
docker compose run --rm --build lint-and-test
```

### Set pytest Options

Sometimes you may want to customize how tests run using [pytest options](https://docs.pytest.org/en/stable/usage.html) when doing development locally, only running a subset of tests using `-k` for example. Simply edit `TEST_ARGS` value in `docker-compose.yaml`, **without** quotes, to set the options you need.

:warning: Committed changes will modify how the build pipeline runs tests

### Set pytest-cov Options

By default test coverage is calculated for files in `./src` and displayed in a table after tests run.

* If you want to see a detailed output, edit `COV_REPORT` value in `docker-compose.yaml` to be `html` and visit `http://localhost:8000/`
* If you want to turn off coverage report generation, edit `COV_REPORT` value in `docker-compose.yaml` to be `off`

:warning: Committed changes will modify how the build pipeline runs tests, **do not** commit `COV_REPORT=html`

### Skip Linting

When developing locally, you might not want to worry about linting when working to make tests pass. Simply edit the `SKIP_LINT` value in `docker-compose.yaml` to be `1`.

:warning: Careful not to commit changes unless you **really** want to not run linting on the build pipeline
