123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- import os
- import unittest
- from flask import Flask
- from flask_testing import LiveServerTestCase
- from kalliope.core.Models import Singleton
- from kalliope.core.ConfigurationManager import BrainLoader
- from kalliope.core.ConfigurationManager import SettingLoader
- from kalliope.core.RestAPI.FlaskAPI import FlaskAPI
- class TestRestAPI(LiveServerTestCase):
- def create_app(self):
- """
- executed once at the beginning of the test
- """
-
- 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
- sl.settings.allowed_cors_origin = "*"
-
- brain_to_test = full_path_brain_to_test
- brain_loader = BrainLoader(file_path=brain_to_test)
- brain = brain_loader.brain
- 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if __name__ == '__main__':
- unittest.main()
|