# JSON Contract File Import

## Getting Started

### Requirements

- Python 3.11
- Docker

### Installation

Create a `.env` file based on the `.env.shadow` and fill in the values:

```bash
$ cp .env.shadow .env
```

Create a virtual env and install the requirements:

```bash
$ make dev_env
```

### Running

You can run the function inside Docker with: `make docker_local_up`.

Then you can trigger an event with `make local_event`

You can also customize the event within the command line.

```bash
make local_event JIRA_TICKET=ACC-8649 USER=aajay
```

Look at the Makefile for the `local_event` args.

**Note:**
You might need to login to Docker with the shared AWS account in order to run the command above:

```bash
$ awsume <shared_profile>
$ make docker_login
```

### Running in QA env

Configure correct env variables in .env:
```
OWSREQUEST_SERVICE_MAP={"ows-abacus-account":"https://qa-ows-abacus-account.theorchard.io","ows-royalties":"https://qa-ows-abacus-royalties.theorchard.io"}
```

Login to assume and put fresh token to the .env file:
```
awsume qa -s
```

In the terminal in the root directory start python from env:

```
source env/bin/activate
python
```

Run the lambda:
```
from app import *;
handler({'import_user': 'slaposhko', 'jira_ticket': 'ACC-8888'}, None);
```

### Testing

You can run the linter and the unit tests locally with: `make lint` and `make test`

Or you can run the linter and the unit tests inside Docker with: `make docker_test`

### Adding new packages

- For dev packages, add them normally to `requirements-dev.txt`
- For regular packages, add the new top level package name
  and optionally version constraints to `requirements-to-freeze.txt`
- Run `make pip_lock_versions`

### Upgrading packages

Regularly running `make pip_lock_versions` will update and freeze all non-dev dependencies in `requirements.txt`
