# ows-asset-file-details

This microservice is used for getting file details associated with assets.
This includes information such as the filename, bits per sample, etc.
The initial use case of this microservice is to provide information from
asset related tables in direct delivery to be used in GraphQL which in turn
will be used for generating DDEX XML for sound recordings. 

## Setup and Usage

Before starting make sure you have python3.6 installed.
An easy way to manage python versions is with pyenv.
```
$ brew update
$ brew install pyenv
$ pyenv install 3.6.8
```

### Configuration

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

Populate your .env file

If you are running locally be sure to set your `Environment=dev`.

Also note that if you are running locally, the `secrets_manager` library
will not connect to AWS and will instead attempt to find an environment
variable for `DD_DB_URL` so be sure to set that environment variable with the format:
`mysql+pymysql://{user}:{password}@{host}:{port}/{database}`

### Installation
```bash
$ python3.6 -m venv env
$ . env/bin/activate
(env) $ pip install --upgrade pip
(env) $ pip install -r requirements.txt
(env) $ pip install -r requirements-dev.txt
```

or

```bash
make pip_dev
```

### Running

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

```bash
$ . env/bin/activate
(env) $ python dev.py
```

or

```bash
make dev
```
All make commands will automatically install all dependencies in an virtual environment folder called env.
You can activate a virtual environment by running `. env/bin/activate` or `source env/bin/activate`.

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

To run the tests, all you have to do is to run:

```bash
(env) $ py.test tests/unit/
(env) $ py.test tests/integration/
(env) $ flake8 video/ tests/
```

or

To run unit tests: `make test`

To run unit tests with coverage reporting: `make test_unit`

To run integration tests: `make test_integration`

To lint: `make lint`

### Updating

To install new dependencies.

```bash
(env) $ pip install -r requirements.txt
(env) $ pip install -r requirements-dev.txt
```

or

```bash
make pip_dev
```

### Environment

This application uses secrets manager for credentials. When running locally,
the secrets manager client will look for env variables instead. Please make
sure to set the following variable for working locally:

```bash
export DD_DB_URL=mysql+pymysql://{user}:{password}@{host}:{port}/{database}
```

This is not included in `.env.shadow` because secrets manager is used in QA and Prod.
