当前位置: 首页>>代码示例>>Python>>正文


Python NavigationBarHook.get_entries方法代码示例

本文整理汇总了Python中reviewboard.extensions.hooks.NavigationBarHook.get_entries方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationBarHook.get_entries方法的具体用法?Python NavigationBarHook.get_entries怎么用?Python NavigationBarHook.get_entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reviewboard.extensions.hooks.NavigationBarHook的用法示例。


在下文中一共展示了NavigationBarHook.get_entries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_navigation_bar_hooks_with_is_enabled_for_legacy

# 需要导入模块: from reviewboard.extensions.hooks import NavigationBarHook [as 别名]
# 或者: from reviewboard.extensions.hooks.NavigationBarHook import get_entries [as 别名]
    def test_navigation_bar_hooks_with_is_enabled_for_legacy(self):
        """Testing NavigationBarHook.is_enabled_for and legacy argument
        format
        """
        def is_enabled_for(user):
            self.assertEqual(user, request.user)

            return True

        entry = {
            'label': 'Test Nav Entry',
            'url': 'foo-url',
        }

        hook = NavigationBarHook(extension=self.extension, entries=[entry],
                                 is_enabled_for=is_enabled_for)

        request = self.client.request()
        request.user = User(username='text')

        context = Context({
            'request': request,
            'local_site_name': 'test-site',
        })
        entries = hook.get_entries(context)
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0], entry)

        t = Template(
            '{% load rb_extensions %}'
            '{% navigation_bar_hooks %}')

        self.assertEqual(t.render(context).strip(),
                         '<li><a href="%(url)s">%(label)s</a></li>' % entry)
开发者ID:Hackthings,项目名称:reviewboard,代码行数:36,代码来源:tests.py

示例2: test_navigation_bar_hooks_with_url_name

# 需要导入模块: from reviewboard.extensions.hooks import NavigationBarHook [as 别名]
# 或者: from reviewboard.extensions.hooks.NavigationBarHook import get_entries [as 别名]
    def test_navigation_bar_hooks_with_url_name(self):
        "Testing navigation entry extension hooks with url names"""
        entry = {
            'label': 'Test Nav Entry',
            'url_name': 'dashboard',
        }

        hook = NavigationBarHook(extension=self.extension, entries=[entry])

        request = self.client.request()
        request.user = User(username='text')

        context = Context({
            'request': request,
            'local_site_name': 'test-site',
        })
        entries = hook.get_entries(context)
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0], entry)

        t = Template(
            '{% load rb_extensions %}'
            '{% navigation_bar_hooks %}')

        self.assertEqual(
            t.render(context).strip(),
            '<li><a href="%(url)s">%(label)s</a></li>' % {
                'label': entry['label'],
                'url': '/dashboard/',
            })
开发者ID:Hackthings,项目名称:reviewboard,代码行数:32,代码来源:tests.py

示例3: test_navigation_bar_hooks_with_is_enabled_for_false

# 需要导入模块: from reviewboard.extensions.hooks import NavigationBarHook [as 别名]
# 或者: from reviewboard.extensions.hooks.NavigationBarHook import get_entries [as 别名]
    def test_navigation_bar_hooks_with_is_enabled_for_false(self):
        """Testing NavigationBarHook.is_enabled_for and returns false"""
        def is_enabled_for(**kwargs):
            self.assertEqual(kwargs['user'], request.user)
            self.assertEqual(kwargs['request'], request)
            self.assertEqual(kwargs['local_site_name'], 'test-site')

            return False

        entry = {
            'label': 'Test Nav Entry',
            'url': 'foo-url',
        }

        hook = NavigationBarHook(extension=self.extension, entries=[entry],
                                 is_enabled_for=is_enabled_for)

        request = self.client.request()
        request.user = User(username='text')

        context = Context({
            'request': request,
            'local_site_name': 'test-site',
        })
        entries = hook.get_entries(context)
        self.assertEqual(len(entries), 0)

        t = Template(
            '{% load rb_extensions %}'
            '{% navigation_bar_hooks %}')

        self.assertEqual(t.render(context).strip(), '')
开发者ID:Hackthings,项目名称:reviewboard,代码行数:34,代码来源:tests.py

示例4: test_navigation_bar_hooks

# 需要导入模块: from reviewboard.extensions.hooks import NavigationBarHook [as 别名]
# 或者: from reviewboard.extensions.hooks.NavigationBarHook import get_entries [as 别名]
    def test_navigation_bar_hooks(self):
        """Testing navigation entry extension hooks"""
        entry = {
            'label': 'Test Nav Entry',
            'url': 'foo-url',
        }

        hook = NavigationBarHook(extension=self.extension, entries=[entry])

        context = Context({})
        entries = hook.get_entries(context)
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0], entry)

        t = Template(
            "{% load rb_extensions %}"
            "{% navigation_bar_hooks %}")

        self.assertEqual(t.render(context).strip(),
                         '<li><a href="%(url)s">%(label)s</a></li>' % entry)
开发者ID:karthikkn,项目名称:reviewboard,代码行数:22,代码来源:tests.py

示例5: test_navigation_bar_hooks_with_url_name

# 需要导入模块: from reviewboard.extensions.hooks import NavigationBarHook [as 别名]
# 或者: from reviewboard.extensions.hooks.NavigationBarHook import get_entries [as 别名]
    def test_navigation_bar_hooks_with_url_name(self):
        "Testing navigation entry extension hooks with url names"""
        entry = {
            'label': 'Test Nav Entry',
            'url_name': 'dashboard',
        }

        hook = NavigationBarHook(extension=self.extension, entries=[entry])

        context = Context({})
        entries = hook.get_entries(context)
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0], entry)

        t = Template(
            "{% load rb_extensions %}"
            "{% navigation_bar_hooks %}")

        self.assertEqual(t.render(context).strip(),
                         '<li><a href="%(url)s">%(label)s</a></li>' % {
                             'label': entry['label'],
                             'url': '/dashboard/',
                         })
开发者ID:karthikkn,项目名称:reviewboard,代码行数:25,代码来源:tests.py


注:本文中的reviewboard.extensions.hooks.NavigationBarHook.get_entries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。