#!/bin/bash

set -e

# defaults if not set
: "${SKIP_LINT:=0}"

# run linting of python files
if [ "$SKIP_LINT" -ne 1 ]; then
    echo 'Running linting...'
    flake8 ytownership/ tests/
else
    echo 'Skipping linting...'
fi

# run pytest with args set
echo 'Running tests...'
export Environment=test
PYTHONPATH="$(pwd)"
export PYTHONPATH

py.test --cov ytownership tests/ \
        --cov-report xml:/var/app/build/coverage.xml \
        --junitxml=/var/app/build/pyunit.xml

echo 'Done!'
