From e64ebac2a8def1a535415ce10d01109c17d983e8 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Tue, 4 May 2021 19:01:25 +0200
Subject: [PATCH] Initial EngineExecutor test case. #72

---
 tests/test.py | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/tests/test.py b/tests/test.py
index 12abd657..5ba891f8 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -21,16 +21,21 @@
 import os
 import unittest
 import validators
+import time
 
 from datetime import datetime
 
+from src.base.utils import SimpleUtil as SU
 from src.base.logger import AuraLogger
 from src.base.config import AuraConfig
-
+from src.control import EngineExecutor
 
 
 
 class TestLogger(unittest.TestCase):
+    """
+    Testing the Logger.
+    """
     aura_logger = None
 
     def setUp(self):
@@ -42,7 +47,9 @@ class TestLogger(unittest.TestCase):
 
 
 class TestConfig(unittest.TestCase):
-
+    """
+    Testing the Configuration.
+    """
     config = None
 
     def setUp(self):
@@ -79,5 +86,33 @@ class TestConfig(unittest.TestCase):
 
 
 
+class TestEngineExecutor(unittest.TestCase):
+    """
+    Testing the EngineExecutor.
+    """
+
+    def setUp(self):
+        None
+
+
+    def test_single_executor(self):
+        # Initialize stae and executor params
+        global_state = ["none"]
+        due_time = SU.timestamp() + 2
+        def f(param):
+            global_state[0] = param
+
+        # Before the executor is done ther should be the initial value
+        e = EngineExecutor("RANDOM_NAMESPACE", None, due_time, f, "hello world")
+        self.assertEqual("none", global_state[0])
+        self.assertNotEqual("hello world", global_state[0])
+
+        # After 3 seconds there should be the updated value
+        time.sleep(5)
+        self.assertEqual("hello world", global_state[0])
+
+
+
+
 if __name__ == '__main__':
     unittest.main()
\ No newline at end of file
-- 
GitLab