Skip to content
Snippets Groups Projects
Commit 97502a95 authored by slobinger's avatar slobinger
Browse files

Merge branch '8-test-samshub-with-proxy' into 'master'

Resolve "test des SMSHub mit  Apps die Proxies haben"

Closes #8

See merge request !5
parents 47bd8f54 647babfa
No related branches found
No related tags found
1 merge request!5Resolve "test des SMSHub mit Apps die Proxies haben"
......@@ -54,7 +54,7 @@ class SAMSApp:
for proxy in self.proxies:
self.__blueprint.add_url_rule(
rule = self._generate_url(proxy.urlRule),
endpoint = self.__blueprint.name + '_proxy_' + str(i),
endpoint = self.__blueprint.name.replace('.', '_') + '_proxy_' + str(i),
view_func = proxy.proxy)
i += 1
......
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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment