From ebb7b4b4ae06e0fdd62ee5f73b5d7dfc05627db0 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Thu, 29 Jun 2017 11:21:55 -0700 Subject: [PATCH] Make data a non-optional arg to add_route We expect at least an empty dict when we fetch it, so let's make it non-optional and always pass in something. This is clearer. --- jupyterhub/proxy.py | 6 +++--- jupyterhub/tests/test_proxy.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jupyterhub/proxy.py b/jupyterhub/proxy.py index 22029441..4e843769 100644 --- a/jupyterhub/proxy.py +++ b/jupyterhub/proxy.py @@ -128,7 +128,7 @@ class Proxy(LoggingConfigurable): return routespec @gen.coroutine - def add_route(self, routespec, target, data=None): + def add_route(self, routespec, target, data): """Add a route to the proxy. **Subclasses must define this method** @@ -331,7 +331,7 @@ class Proxy(LoggingConfigurable): def add_hub_route(self, hub): """Add the default route for the Hub""" self.log.info("Adding default route for Hub: / => %s", hub.host) - return self.add_route('/', self.hub.host) + return self.add_route('/', self.hub.host, {'hub': True}) @gen.coroutine def restore_routes(self): @@ -521,7 +521,7 @@ class ConfigurableHTTPProxy(Proxy): return client.fetch(req) - def add_route(self, routespec, target, data=None): + def add_route(self, routespec, target, data): body = data or {} body['target'] = target body['jupyterhub'] = True diff --git a/jupyterhub/tests/test_proxy.py b/jupyterhub/tests/test_proxy.py index a8d641c7..962e9c4e 100644 --- a/jupyterhub/tests/test_proxy.py +++ b/jupyterhub/tests/test_proxy.py @@ -204,7 +204,7 @@ def test_add_get_delete(app, routespec): proxy = app.proxy target = 'https://localhost:1234' with context(): - yield proxy.add_route(arg, target=target) + yield proxy.add_route(arg, target=target, {}) routes = yield proxy.get_all_routes() if not expect_value_error: assert routespec in routes.keys()