#!/bin/bash

set -e

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

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

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

/var/app/bin/py.test $TEST_ARGS --cov video tests/ \
		--cov-report xml:/var/app/build/coverage.xml \
		--junitxml=/var/app/build/pyunit.xml

echo 'Done!'
