diff --git a/tests/unit_tests/test_tethys_apps/test_base/test_controller.py b/tests/unit_tests/test_tethys_apps/test_base/test_controller.py index 419790189..cabd670ac 100644 --- a/tests/unit_tests/test_tethys_apps/test_base/test_controller.py +++ b/tests/unit_tests/test_tethys_apps/test_base/test_controller.py @@ -259,3 +259,24 @@ def test_register_controllers_catch_all( mock_UrlMap.assert_called_with( name="catch_all", url="root/.*/", controller=mock_controller ) + + def test__get_url_map_kwargs_list_url_dict(self): + result = tethys_controller._get_url_map_kwargs_list( + url={ + "test": "test/url/", + "another_test": "test/{another}/url/", + } + ) + self.assertEqual(result[0]["title"], "Test") + self.assertEqual(result[1]["title"], "Another Test") + + def test__get_url_map_kwargs_list_url_list(self): + result = tethys_controller._get_url_map_kwargs_list( + name="test", + url=[ + "test/url/", + "test/{another}/url/", + ], + ) + self.assertEqual(result[0]["title"], "Test") + self.assertEqual(result[1]["title"], "Test 1") diff --git a/tethys_apps/base/controller.py b/tethys_apps/base/controller.py index c1f9d6a9e..b6cc7c6aa 100644 --- a/tethys_apps/base/controller.py +++ b/tethys_apps/base/controller.py @@ -821,9 +821,6 @@ def _get_url_map_kwargs_list( for i, final_url in enumerate(final_urls) } - if not title: - title = url_name.replace("_", " ").title() - return [ dict( name=url_name, @@ -833,7 +830,7 @@ def _get_url_map_kwargs_list( regex=regex, handler=handler, handler_type=handler_type, - title=title, + title=title or url_name.replace("_", " ").title(), index=index, ) for url_name, final_url in final_urls.items() @@ -950,7 +947,7 @@ def register_controllers( UrlMap = url_map_maker(root_url) url_maps = [UrlMap(**kwargs) for name, kwargs in names.items()] - # Add a catch all endpoint for any URL following the app's root URL and map it to the named controller + # Add a catch-all endpoint for any URL following the app's root URL and map it to the named controller if catch_all and catch_all in names: url_maps.append( UrlMap(