Commit 1b8b7aab authored by Alexander Lercher's avatar Alexander Lercher

Fixed integration test in role-stage-discovery

parent 6706e220
......@@ -3,6 +3,14 @@ import sys
import importlib.util
import pathlib
'''
This script searches for all 'tests/' directories and executes all tests
by cd'ing into the dir and executing unittest discover.
It additionally installs all dependencies from a '../requirements.txt' via pip.
Use command line argument '-w' to run on windows.
'''
PY = 'py' if (len(sys.argv) > 1 and sys.argv[1] == '-w') else 'python3.7' # use -w to run on windows
ROOT = pathlib.Path(__file__).parent.parent.absolute()
TESTS_FOLDER_NAME = os.path.normpath("/tests")
......@@ -14,14 +22,15 @@ for (dirname, dirs, files) in os.walk(ROOT):
#I assume all the tests are placed in a folder named "tests"
if (TESTS_FOLDER_NAME in str(dirname)) \
and 'src' in str(dirname) \
and not(f"{TESTS_FOLDER_NAME}{os.path.normpath('/')}" in str(dirname)) \
and not("venv" in str(dirname)):
try:
print(f"Executing tests in {dirname}")
os.chdir(os.path.normpath(dirname))
# TODO do this during docker image setup
exit_val = os.system("python3.7 -m pip install -r ../requirements.txt") # install pip dependencies
exit_val = os.system("python3.7 -m unittest discover") # execute the tests
exit_val = os.system(f"{PY} -m pip install -r ../requirements.txt") # install pip dependencies
exit_val = os.system(f"{PY} -m unittest discover") # execute the tests
resultCodeList.append(exit_val) #once per folder i.e if 3 tests are in a folder and crash, there will be just one exit val
except Exception as e:
print(e)
......
import unittest
import sys
for path in ['../', './', '../../../modules/']:
for path in ['../', './', '../../../modules/', '../../../../modules']:
sys.path.insert(1, path)
from db.entities.connected_node import NodeC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment