ows-account
===========

Accounts are our clients. These include vendors (labels and distributors) and subaccounts.

## Getting Started

### Installation

The installation is very straightforward, but make sure you are using at least
python 3.11. If you use a Mac, you can install it using `brew`. If you use
Windows, just ask for a remote VM that has it installed for you.

```bash
$ uv sync
```

### Running

When all dependencies have been installed, you can run the flask application
on your local instance by running:

```bash
$ make dev
```

You may provide an optional PORT environment variable if you wish to run on
a specific port:

```bash
$ PORT=5002 make dev
```

By using the development server, you will have access to specific features that
are not necessarily available in production, such as the exception tracer.

### Testing

You can use `make test` or `make lint` to run unit tests or lint respectively.
`make test` runs both the unit and the integration tests. You'll need the dev
server running (`make dev`) for the integration tests.

For the integration tests, you need to execute the `awsume prod` command to set your AWS prod account credentials.
Once you have these credentials, the integration tests will be able to get the necessary secrets to generate a proper JWT for use in the tests.
Make you are in the proper application family to access the secrets.

### Developing (Docker)

1. Make sure you've set up your `.env` file:

```
cp .env.shadow .env
```

FILL out `.env` accordingly

2. Load your environment:

```bash
awsume prod
source .env
```

3. Run the hot-reload version of the ows-account Docker image - it watches for changes on your volume/laptop:

```bash
make up
```

You can make requests against it at http://localhost:8888.

4. If you feel the need to run the deploy-version of the ows-account Docker image (it's uwsgi):

```bash
make up_deploy
```

You can make requests against it at http://localhost:8889.

5. When you're done, bring down your Docker containers:

```bash
make down
```

##### Installing pre-commit hook (optional)

If you want the linter to run before you commit, run
```
cp .pre-commit-config.yaml.shadow .pre-commit-config.yaml
pre-commit install
```

If you don't want it to block your commit but just show you what's up, you'll
have to add
```
args: [--exit-zero]
verbose: true
```
to the ruff hook, and comment out the `ruff-format` hook.
