|
@@ -3,8 +3,9 @@ import os
|
|
|
import unittest
|
|
|
|
|
|
import requests
|
|
|
-import time
|
|
|
from flask import Flask
|
|
|
+from flask_testing import LiveServerTestCase
|
|
|
+
|
|
|
from kalliope.core.Models import Singleton
|
|
|
|
|
|
from kalliope.core.ConfigurationManager import BrainLoader
|
|
@@ -12,56 +13,39 @@ from kalliope.core.ConfigurationManager import SettingLoader
|
|
|
from kalliope.core.RestAPI.FlaskAPI import FlaskAPI
|
|
|
|
|
|
|
|
|
-class TestRestAPI(unittest.TestCase):
|
|
|
+class TestRestAPI(LiveServerTestCase):
|
|
|
|
|
|
- @classmethod
|
|
|
- def setUpClass(cls):
|
|
|
+ def create_app(self):
|
|
|
"""
|
|
|
executed once at the beginning of the test
|
|
|
"""
|
|
|
- super(TestRestAPI, cls).setUpClass()
|
|
|
+
|
|
|
+ Singleton._instances = {}
|
|
|
current_path = os.getcwd()
|
|
|
full_path_brain_to_test = current_path + os.sep + "Tests/brains/brain_test.yml"
|
|
|
print full_path_brain_to_test
|
|
|
+
|
|
|
|
|
|
sl = SettingLoader()
|
|
|
sl.settings.rest_api.password_protected = False
|
|
|
sl.settings.active = True
|
|
|
sl.settings.port = 5000
|
|
|
|
|
|
- print sl.settings.rest_api.password_protected
|
|
|
-
|
|
|
-
|
|
|
- Singleton._instances = {}
|
|
|
|
|
|
brain_to_test = full_path_brain_to_test
|
|
|
brain_loader = BrainLoader(file_path=brain_to_test)
|
|
|
brain = brain_loader.brain
|
|
|
|
|
|
- print brain_loader.yaml_config
|
|
|
-
|
|
|
- app = Flask(__name__)
|
|
|
- cls.flask_api = FlaskAPI(app, port=5000, brain=brain)
|
|
|
- cls.flask_api.start()
|
|
|
- time.sleep(1)
|
|
|
+ self.app = Flask(__name__)
|
|
|
+ self.flask_api = FlaskAPI(self.app, port=5000, brain=brain)
|
|
|
+ self.flask_api.app.config['TESTING'] = True
|
|
|
+ return self.flask_api.app
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- def setUp(self):
|
|
|
- self.base_url = "http://127.0.0.1:5000"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -123,10 +107,11 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -152,7 +137,7 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -165,7 +150,7 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -192,7 +177,7 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -205,7 +190,7 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -233,7 +218,7 @@ class TestRestAPI(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|