From a5007d7c18e596a37ece3724d65250c2eb76e0a4 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 25 Jul 2018 15:24:28 +0200 Subject: [PATCH 1/4] Add group_index to LEGACY_ROUTE_NAMES --- ckan/lib/helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index c912dbde4e7..8b449746d02 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -69,6 +69,7 @@ 'home': 'home.index', 'about': 'home.about', 'search': 'dataset.search', + 'group_index': 'group.index', 'organizations_index': 'organization.index' } From 46df511b1e0a6e270e3da2426a7256d98355a13e Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 25 Jul 2018 15:24:59 +0200 Subject: [PATCH 2/4] Test h.build_main_nav with flask and pylons routes --- ckan/tests/lib/test_helpers.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py index 21d5a28c639..7dcc748fc46 100644 --- a/ckan/tests/lib/test_helpers.py +++ b/ckan/tests/lib/test_helpers.py @@ -532,6 +532,38 @@ def test_non_string(self): u'2018-01-05 10:48:23.463511') +class TestBuildNavMain(object): + def test_flask_routes(self): + menu = ( + ('home.index', 'Home'), + ('dataset.search', 'Datasets'), + ('organization.index', 'Organizations'), + ('group.index', 'Groups'), + ('home.about', 'About') + ) + eq_(h.build_nav_main(menu), ( + '
  • Home
  • ' + '
  • Datasets
  • ' + '
  • Organizations
  • ' + '
  • Groups
  • ' + '
  • About
  • ')) + + def test_legacy_pylon_routes(self): + menu = ( + ('home', 'Home'), + ('search', 'Datasets'), + ('organizations_index', 'Organizations'), + ('group_index', 'Groups'), + ('about', 'About') + ) + eq_(h.build_nav_main(menu), ( + '
  • Home
  • ' + '
  • Datasets
  • ' + '
  • Organizations
  • ' + '
  • Groups
  • ' + '
  • About
  • ')) + + class TestHelperException(helpers.FunctionalTestBase): @raises(ckan.exceptions.HelperError) From 4485870fd8c83e19e8ce1d2b61c322de2afc59b6 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 25 Jul 2018 16:28:26 +0200 Subject: [PATCH 3/4] Pass *menu to build_nav_main --- ckan/tests/lib/test_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py index 7dcc748fc46..afe236f1bbd 100644 --- a/ckan/tests/lib/test_helpers.py +++ b/ckan/tests/lib/test_helpers.py @@ -541,7 +541,7 @@ def test_flask_routes(self): ('group.index', 'Groups'), ('home.about', 'About') ) - eq_(h.build_nav_main(menu), ( + eq_(h.build_nav_main(*menu), ( '
  • Home
  • ' '
  • Datasets
  • ' '
  • Organizations
  • ' @@ -556,7 +556,7 @@ def test_legacy_pylon_routes(self): ('group_index', 'Groups'), ('about', 'About') ) - eq_(h.build_nav_main(menu), ( + eq_(h.build_nav_main(*menu), ( '
  • Home
  • ' '
  • Datasets
  • ' '
  • Organizations
  • ' From cd6f6430e38962391182fe1d33f83830a77c2b67 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Thu, 26 Jul 2018 10:49:03 +0200 Subject: [PATCH 4/4] Add missing trailing slashes to URL in test --- ckan/tests/lib/test_helpers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py index afe236f1bbd..d95e8dc14b0 100644 --- a/ckan/tests/lib/test_helpers.py +++ b/ckan/tests/lib/test_helpers.py @@ -543,9 +543,9 @@ def test_flask_routes(self): ) eq_(h.build_nav_main(*menu), ( '
  • Home
  • ' - '
  • Datasets
  • ' - '
  • Organizations
  • ' - '
  • Groups
  • ' + '
  • Datasets
  • ' + '
  • Organizations
  • ' + '
  • Groups
  • ' '
  • About
  • ')) def test_legacy_pylon_routes(self): @@ -558,9 +558,9 @@ def test_legacy_pylon_routes(self): ) eq_(h.build_nav_main(*menu), ( '
  • Home
  • ' - '
  • Datasets
  • ' - '
  • Organizations
  • ' - '
  • Groups
  • ' + '
  • Datasets
  • ' + '
  • Organizations
  • ' + '
  • Groups
  • ' '
  • About
  • '))