From fcef1cfc6639a2382bfe2502c032ac9e255ccba0 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Thu, 8 Jul 2021 17:02:22 +0200
Subject: [PATCH] Run test cases with virtual environment. #78

---
 docs/developer-guide.md | 13 +++++++++++--
 run.sh                  |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/docs/developer-guide.md b/docs/developer-guide.md
index d3f2c407..240da016 100644
--- a/docs/developer-guide.md
+++ b/docs/developer-guide.md
@@ -7,7 +7,8 @@ This page gives insights on extending Aura Engine internals or through the API.
 - [Aura Engine Development Guide](#aura-engine-development-guide)
     - [AURA Componentes](#aura-componentes)
     - [Engine Components](#engine-components)
-    - [Running Engine for Development](#running-engine-for-development)
+    - [Running for Development](#running-for-development)
+    - [Testing](#testing)
     - [API](#api)
     - [Scheduler](#scheduler)
     - [Docker](#docker)
@@ -46,7 +47,7 @@ There's a convenience script to start all of the three main dependencies (Steeri
 *...TBD...*
 
 
-## Running Engine for Development
+## Running for Development
 
 Ensure you have following other projects up and running:
 
@@ -70,6 +71,14 @@ Now start Liquidsoap which is part of Engine Core:
 
 If your IDE of choice is *Visual Studio Code*, then there are launch settings provided in `.vscode/launch.json`.
 
+## Testing
+
+Test cases are located in `./tests`. The test command expects a virtual environment in `./python` which gets activated automatically as soon you run the tests with
+
+```shell
+~/code/aura/engine$ ./run.sh test
+```
+
 ## API
 
 You can find the AURA API definition here: https://gitlab.servus.at/autoradio/meta/blob/master/api-definition.md
diff --git a/run.sh b/run.sh
index b151e671..c4f93505 100755
--- a/run.sh
+++ b/run.sh
@@ -57,7 +57,9 @@ if [[ $docker == "false" ]]; then
 	### Runs Tests ###
 
 	if [[ $mode == "test" ]]; then
-		/usr/bin/env $PYTHON_EXEC -m unittest discover tests
+		source python/bin/activate
+		echo "Running Engine Tests in Python Environment ($(python3 -V))"
+		python -m unittest discover tests
 	fi
 
 	### CAUTION: This deletes everything in your database ###
-- 
GitLab