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

extend test_menu_list_provided to reflect new state of issue #29

the test checks that the appAlias is also provides by menu context
processor of the hub

changed files:
test/test_sams_hub.py
parent f8b9a90d
Branches
Tags
1 merge request!21Resolve "Apps sollen mit Alias an Hub angemeldet werden können"
......@@ -18,12 +18,12 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
apiApp.config['TESTING'] = True
thApi = FlaskInThread(apiApp, host="localhost", port=4711)
thApi.start()
time.sleep(0.01)
time.sleep(1)
def tearDown(self):
response = requests.get('http://localhost:4711/shutdown')
print(response.content.decode('utf-8'))
time.sleep(0.01)
time.sleep(1)
def test_hub_provides_apps_with_proxies(self):
manifest = {
......@@ -223,14 +223,7 @@ class CaseMinimalSAMSHub(unittest.TestCase):
]
urls = ['1/1', '2/1', '1/2']
name_vars = ['1_1', '2_1', '1_2']
expected = ''.join((
"<ul>\n\n<li><a href='/", name, '/', urls[0], "'>", expected_names[0],
"</a>\n\n<ul>\n\n<li><a href='/", name, '/', urls[1], "'>", expected_names[1],
"</a>\n\n</li>\n\n</ul>\n\n</li>\n\n<li><a href='/", name, '/', urls[2], "'>",
expected_names[2], '</a>\n\n</li>\n\n</ul>'
))
self.hub.addApp(
SAMSApp(
testSamsApp = SAMSApp(
name = name, manifest = {
'default_language': 'de',
'views': [{'url': 'test-menu','function': 'views.menu_test'}],
......@@ -242,13 +235,25 @@ class CaseMinimalSAMSHub(unittest.TestCase):
]
}
, langDict = {'de': dict(zip(name_vars, expected_names))}
)
)
self.hub.flaskApp.config['DEBUG'] = True
with self.hub.flaskApp.test_client(self) as client:
response = client.get('/test/test-menu')
self.assertIs(response.status_code, 200)
self.assertEquals(response.data.decode('utf-8'), expected)
for addAppParams in (
{'app': testSamsApp}, {'app': testSamsApp, 'alias': 'testAlias'}):
hub = SAMSHub(name = 'test', config = {'default_language': 'de'})
effectiveName = addAppParams.get('alias', name)
expected = ''.join((
"<ul>\n\n<li><a href='/", effectiveName, '/', urls[0], "'>",
expected_names[0], "</a>\n\n<ul>\n\n<li><a href='/", effectiveName,
'/', urls[1], "'>", expected_names[1],
"</a>\n\n</li>\n\n</ul>\n\n</li>\n\n<li><a href='/", effectiveName, '/',
urls[2], "'>", expected_names[2], '</a>\n\n</li>\n\n</ul>'
))
hub.addApp(**addAppParams)
hub.flaskApp.config['DEBUG'] = True
with hub.flaskApp.test_client(self) as client:
response = client.get('/' + effectiveName + '/test-menu')
with self.subTest(addAppParams):
self.assertIs(response.status_code, 200)
self.assertEquals(response.data.decode('utf-8'), expected)
def test_hub_default_language_used(self):
"""The hub default_language is prefered instead of app default_language"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment