コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
def raw_breadcrumbs():
    """Returns the breadcrumbs for the current request."""

    return breadcrumbs(request.path, locale().code)