diff --git a/debian/changelog b/debian/changelog index c5bce69bfd17101e4eed90ab90d51cd6028b59b1..f8208efe18bd5e6af73846fcd9e42d5b5466fe91 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,12 @@ -python3-sams-classes (1.0.1~3) UNRELEASED; urgency=medium +python3-sams-classes (1.0.1~4) UNRELEASED; urgency=medium * fixed issue #20 "Basis-Pfad (/) bei API über Proxy nicht aufrufbar" * fixed issue #21 "Unterstützung von anderen HTTP-Methoden als GET innerhalb einer APP" * Fixed issue #24 "main app sollte auch unter /appname/,,, ereichbar sein" + * Fixed issue #23 "static ordner je app ermöglichen" - -- Sebastian Lobinger <slobinger@justus.zib.de> Wed, 14 Jun 2017 14:29:26 +0200 + - Sebastian Lobinger <slobinger@justus.zib.de> Wed, 14 Jun 2017 15:39:31 +0200 python3-sams-classes (1.0.0) unstable; urgency=medium diff --git a/sams_classes/sams_app.py b/sams_classes/sams_app.py index c7e709f6e122f1d6d324918ce72ff5250fc1e0a0..bbbfc0eda90f1f896f7770a4019271ac6e7edd0d 100644 --- a/sams_classes/sams_app.py +++ b/sams_classes/sams_app.py @@ -15,7 +15,8 @@ class SAMSApp: def __init__(self, name, manifest = {} , langDict = {}, urlPrefix = ''): self.__name = name - self.__blueprint = Blueprint(name, name, template_folder='templates') + self.__blueprint = Blueprint(name, name, template_folder='templates', + static_folder = 'static') self.__manifest = manifest self.__urlPrefix = urlPrefix if not self.manifest.get('default_language'): diff --git a/test/app/static/test.txt b/test/app/static/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..30d74d258442c7c65512eafab474568dd706c430 --- /dev/null +++ b/test/app/static/test.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/static/test.txt b/test/static/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..30d74d258442c7c65512eafab474568dd706c430 --- /dev/null +++ b/test/static/test.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/test_sams_hub.py b/test/test_sams_hub.py index 35d50c8b74a03d6c80b9b3f223f3624c6a0c280e..ac6b12f0bfaaea09d7c2074035ab20326200fc45 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):