Skip to content
Snippets Groups Projects
Commit 0e6a257b authored by slobinger's avatar slobinger
Browse files

Merge branch '29-alias-for-apps' into 'master'

Resolve "Apps sollen mit Alias an Hub angemeldet werden können"

Closes #29

See merge request !20
parents 9461376b a0d39e81
No related branches found
No related tags found
1 merge request!20Resolve "Apps sollen mit Alias an Hub angemeldet werden können"
Pipeline #
python3-sams-classes (1.0.3~1) UNRELEASED; urgency=medium
* fixed issue #29 "Apps sollen mit Alias an Hub angemeldet werden können"
-- Lobinger <slobinger@justus.zib.de> Thu, 22 Jun 2017 08:43:01 +0200
python3-sams-classes (1.0.2) unstable; urgency=medium python3-sams-classes (1.0.2) unstable; urgency=medium
* fixed issue #27 "Proxy muss alle HTTP-Methoden unterstützen" * fixed issue #27 "Proxy muss alle HTTP-Methoden unterstützen"
......
...@@ -30,7 +30,7 @@ class SAMSHub: ...@@ -30,7 +30,7 @@ class SAMSHub:
self._flaskApp.context_processor(self._context_processor) self._flaskApp.context_processor(self._context_processor)
self._flaskApp.secret_key = 'my awesome SAMSHub secret_key' self._flaskApp.secret_key = 'my awesome SAMSHub secret_key'
def addApp(self, app: SAMSApp = None): def addApp(self, app: SAMSApp = None, alias = None):
if not isinstance(app, SAMSApp): if not isinstance(app, SAMSApp):
raise TypeError('Argument app has to be a SAMSApp.') raise TypeError('Argument app has to be a SAMSApp.')
self._apps[app.name] = app self._apps[app.name] = app
...@@ -38,7 +38,7 @@ class SAMSHub: ...@@ -38,7 +38,7 @@ class SAMSHub:
if app.name == self._config.get('main_app'): if app.name == self._config.get('main_app'):
self._flaskApp.register_blueprint(app.blueprint) self._flaskApp.register_blueprint(app.blueprint)
self._flaskApp.register_blueprint( self._flaskApp.register_blueprint(
app.blueprint, url_prefix = '/' + app.name) app.blueprint, url_prefix = '/' + (alias or app.name))
@property @property
def appKeys(self): def appKeys(self):
......
__version__ = '1.0.2' __version__ = '1.0.3'
\ No newline at end of file \ No newline at end of file
...@@ -33,12 +33,14 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase): ...@@ -33,12 +33,14 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
self.hub.addApp( self.hub.addApp(
SAMSApp(name = 'test',manifest = manifest, langDict={'de':{}}) SAMSApp(name = 'test',manifest = manifest, langDict={'de':{}})
) )
self.hub.addApp( testApp = SAMSApp(name = 'test.app', manifest = manifest, langDict={'de':{}})
SAMSApp(name = 'test.app', manifest = manifest, langDict={'de':{}}) self.hub.addApp(app = testApp)
) self.hub.addApp(app = testApp, alias = 'test')
with self.hub.flaskApp.test_client() as client: with self.hub.flaskApp.test_client() as client:
self.assertIs(client.get(path='/api/hello').status_code, 200) for urlPrefix in ('', '/test.app', '/test'):
self.assertIs(client.get(path='/test.app/api/hello').status_code, 200) with self.subTest(urlPrefix):
self.assertIs(client.get(
path = urlPrefix + '/api/hello').status_code, 200)
class CaseSAMSHubWithMainApp(unittest.TestCase): class CaseSAMSHubWithMainApp(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment