#!/bin/bash
# WF 2022-08-20

#
# install packages
#
install_packages() {
  # install test packages
  pip install aiohttp asynctest green psutil selenium  testfixtures webdriver-manager
  # install example packages
  pip install bokeh pandas pydeck
}

#
# test module by module
#
modulewise_test() {
  foundErrors=0
  for testmodule in tests/test*.py
  do
    echo "testing $testmodule ..."
    # see https://github.com/CleanCut/green/issues/263
    #green $testmodule -s1
    python -m unittest $testmodule
    exit_code=$?
    foundErrors=$((foundErrors+exit_code))
  done
  if [[ $foundErrors -gt 0 ]]
  then
    exit 1
  fi
}

install_packages
#modulewise_test
# test importability might fail if we do this ...
green tests -s 1
