Skip to content
Snippets Groups Projects

Resolve "test des SMSHub mit Apps die Proxies haben"

Merged slobinger requested to merge 8-test-samshub-with-proxy into master
1 file
+ 34
2
Compare changes
  • Side-by-side
  • Inline
+ 34
2
import unittest
import unittest, requests
from sams_classes import SAMSHub, SAMSApp
from sams_classes.exceptions import AppNotExist
from flask import Flask, Blueprint
import sys
import sys, time
from .helper_classes import FlaskInThread
def eprint(*args, **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):
def setUp(self):
Loading