From 77541e9c48049c4a3ab0bd22d09aed83b587b8cf Mon Sep 17 00:00:00 2001 From: Sebastian Lobinger <sebastian.lobinger@fu-berlin.de> Date: Wed, 14 Jun 2017 15:30:33 +0200 Subject: [PATCH] add test_static_files to test_sams_hub.py to test for issue #23 --- test/test_sams_hub.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/test/test_sams_hub.py b/test/test_sams_hub.py index 35d50c8..ac6b12f 100644 --- a/test/test_sams_hub.py +++ b/test/test_sams_hub.py @@ -42,13 +42,15 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase): class CaseSAMSHubWithMainApp(unittest.TestCase): - def test_main_app(self): - """It is possible to declare a main app where the urls have no prefix""" - szenarios = [ + def setUp(self): + self.szenarios = [ {'main_app': 'test', 'extra_app': 'test.app'}, {'main_app': 'test.app', 'extra_app': 'test'} - ] - for szenario in szenarios: + ] + + def test_main_app(self): + """It is possible to declare a main app where the urls have no prefix""" + for szenario in self.szenarios: main_app = szenario['main_app'] extra_app = szenario['extra_app'] with self.subTest(main_app = main_app, extra_app = extra_app): @@ -111,6 +113,31 @@ class CaseSAMSHubWithMainApp(unittest.TestCase): response = client.get(path) self.assertIs(response.status_code, 200) + def test_static_files(self): + for szenario in self.szenarios: + main_app = szenario['main_app'] + extra_app = szenario['extra_app'] + hub = SAMSHub( name = 'test', + config = {'default_language': 'de', 'main_app' : ''.join(main_app)} + ) + hub.addApp( + SAMSApp( name = main_app, manifest = {'default_language': 'de'}, + langDict = {'de': {}} + ) + ) + hub.addApp( + SAMSApp( name = extra_app, manifest = {'default_language': 'de'}, + langDict = {'de': {}} + ) + ) + hub.flaskApp.config['DEBUG'] = True + with self.subTest(main_app = main_app, extra_app = extra_app): + for static_url in ('/test/static/', '/test.app/static/'): + with hub.flaskApp.test_client(self) as client: + with self.subTest(static_url): + response = client.get(static_url + 'test.txt') + self.assertIs(response.status_code, 200) + class CaseSAMSHubInitExceptions(unittest.TestCase): def test_missing_init_name(self): -- GitLab