def test_localizes_static_parts_of_the_url(self): path = '/courses/foobar/lessons' expected = [{ 'url': '/', 'label': 'Startseite' }, { 'url': '/courses', 'label': 'Kurse' }, { 'url': '/courses/foobar', 'label': 'foobar' }, { 'url': '/courses/foobar/lessons', 'label': 'Lektionen' }] self.assertEqual(breadcrumbs(path, 'de-DE'), expected)
def test_add_all_parts_of_the_url(self): path = '/courses/foobar/lessons' expected = [{ 'url': '/', 'label': 'Home' }, { 'url': '/courses', 'label': 'Courses' }, { 'url': '/courses/foobar', 'label': 'foobar' }, { 'url': '/courses/foobar/lessons', 'label': 'Lessons' }] self.assertEqual(breadcrumbs(path, 'en-US'), expected)
def test_does_nothing_if_no_slugs_match(self): path = '/courses/foobar/lessons' expected = [{ 'url': '/', 'label': 'Startseite' }, { 'url': '/courses', 'label': 'Kurse' }, { 'url': '/courses/foobar', 'label': 'foobar' }, { 'url': '/courses/foobar/lessons', 'label': 'Lektionen' }] self.assertEqual(refine(breadcrumbs(path, 'de-DE'), MockResource()), expected)
def test_replaces_dynamic_parts_of_urls_with_resource_titles_if_slugs_math( self): path = '/courses/foobar/lessons' expected = [{ 'url': '/', 'label': 'Startseite' }, { 'url': '/courses', 'label': 'Kurse' }, { 'url': '/courses/foobar', 'label': 'Some Foobar!' }, { 'url': '/courses/foobar/lessons', 'label': 'Lektionen' }] self.assertEqual( refine(breadcrumbs(path, 'de-DE'), MockResource('foobar', 'Some Foobar!')), expected)
def raw_breadcrumbs(): """Returns the breadcrumbs for the current request.""" return breadcrumbs(request.path, locale().code)