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


Python Category.slug方法代码示例

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


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

示例1: test_category_with_empty_name_should_display_does_not_exist_page

# 需要导入模块: from rango.models import Category [as 别名]
# 或者: from rango.models.Category import slug [as 别名]
    def test_category_with_empty_name_should_display_does_not_exist_page(self):
        """
        This test tests how rango reacts to trying to render a category with an empty name.
        """

        category = Category(name='')
        category.slug=category.name
        try:
            response = self.client.get(reverse('category', args=(category.slug,)))
        except NoReverseMatch as nrm:
            self.fail(msg="The category slug that caused failure is: {}\n \
                {}".format(category.slug, nrm))
        # We should get a HTTP 200 on a non-existent category.
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Category Does Not Exist")
        self.assertEqual('', category.slug)
开发者ID:stallmanifold,项目名称:rango,代码行数:18,代码来源:tests.py

示例2: test_category_that_does_not_exist

# 需要导入模块: from rango.models import Category [as 别名]
# 或者: from rango.models.Category import slug [as 别名]
    def test_category_that_does_not_exist(self):
        """
        Test that rango responds correctly when the user tries to 
        go to a category that does not exist.
        """

        # We don't want to save the category because we are interested in 
        # what the view does with a nonexistent category.
        category = Category(name='non_existent_test_category')
        category.slug = category.name
        # If the URL resolver throws an exception, just fail fast.
        try:
            response = self.client.get(reverse('category', args=(category.slug,)))
        except NoReverseMatch as nrm:
            self.fail(msg="The category slug that caused failure is: {}\n \
                {}".format(category.slug, nrm))
        # We should get a HTTP 200 on a non-existent category.
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Category Does Not Exist")
        self.assertContains(response, 
            "The specified category <strong>{}</strong> does not exist!".format(category.slug))
开发者ID:stallmanifold,项目名称:rango,代码行数:23,代码来源:tests.py


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