#!/bin/sh -ex

if [ -z "$ENV" ]
then
  pipenv run python dev.py &> /dev/null &

  # get the PID of flask server
  DEV_SERVER_PID=$!

  # wait for server to spin up
  sleep 5
fi

pipenv run py.test \
  --ignore=tests/integration/load \
  --ignore=tests/integration/models \
  tests/integration

if [ -z "$ENV" ]
then
  kill $DEV_SERVER_PID
fi
