Skip to content
Snippets Groups Projects
Commit f5b6b6bf authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

add test_hub_provides_apps_with_proxies to test_sams_hub.py see #8

parent 47bd8f54
No related branches found
No related tags found
1 merge request!5Resolve "test des SMSHub mit Apps die Proxies haben"
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
import unittest import unittest, requests
from sams_classes import SAMSHub, SAMSApp from sams_classes import SAMSHub, SAMSApp
from sams_classes.exceptions import AppNotExist from sams_classes.exceptions import AppNotExist
from flask import Flask, Blueprint from flask import Flask, Blueprint
import sys import sys, time
from .helper_classes import FlaskInThread
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs) print(*args, file=sys.stderr, **kwargs)
class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
def setUp(self):
self.hub = SAMSHub(
name = 'test', config = {'default_language': 'de', 'main_app' : 'test'})
from .api_test_server import app as apiApp
apiApp.config['TESTING'] = True
thApi = FlaskInThread(apiApp, host="localhost", port=4711)
thApi.start()
time.sleep(0.01)
def tearDown(self):
response = requests.get('http://localhost:4711/shutdown')
print(response.content.decode('utf-8'))
time.sleep(0.01)
def test_hub_provides_apps_with_proxies(self):
manifest = {
'default_language': 'de',
'proxies': [{'in': 'api', 'out': 'http://localhost:4711'}]
}
self.hub.addApp(
SAMSApp(name = 'test',manifest = manifest, langDict={'de':{}})
)
self.hub.addApp(
SAMSApp(name = 'test.app', manifest = manifest, langDict={'de':{}})
)
with self.hub.flaskApp.test_client() as client:
self.assertIs(client.get(path='/api/hello').status_code, 200)
self.assertIs(client.get(path='/test.app/api/hello').status_code, 200)
class CaseSAMSHubWithMainApp(unittest.TestCase): class CaseSAMSHubWithMainApp(unittest.TestCase):
def setUp(self): def setUp(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment