本文整理汇总了Python中badger.models.Badge.get_absolute_url方法的典型用法代码示例。如果您正苦于以下问题:Python Badge.get_absolute_url方法的具体用法?Python Badge.get_absolute_url怎么用?Python Badge.get_absolute_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badger.models.Badge
的用法示例。
在下文中一共展示了Badge.get_absolute_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_badge_detail
# 需要导入模块: from badger.models import Badge [as 别名]
# 或者: from badger.models.Badge import get_absolute_url [as 别名]
def test_badge_detail(self):
"""Can view badge detail"""
user = self._get_user()
badge = Badge(creator=user, title="Test II", description="Another test")
badge.save()
r = self.client.get(reverse("badger.views.detail", args=(badge.slug,)), follow=True)
doc = pq(r.content)
eq_("badge_detail", doc.find("body").attr("id"))
eq_(1, doc.find('.badge-title:contains("%s")' % badge.title).length)
eq_(badge.description, doc.find(".badge .description").text())
# Now, take a look at the JSON format
url = reverse("badger.detail_json", args=(badge.slug,))
r = self.client.get(url, follow=True)
data = simplejson.loads(r.content)
eq_(badge.title, data["name"])
eq_(badge.description, data["description"])
eq_("http://testserver%s" % badge.get_absolute_url(), data["criteria"])
示例2: test_badge_detail
# 需要导入模块: from badger.models import Badge [as 别名]
# 或者: from badger.models.Badge import get_absolute_url [as 别名]
def test_badge_detail(self):
"""Can view badge detail"""
user = self._get_user()
badge = Badge(creator=user, title="Test II",
description="Another test")
badge.save()
r = self.client.get(reverse('badger.views.detail',
args=(badge.slug,)), follow=True)
doc = pq(r.content)
eq_('badge_detail', doc.find('body').attr('id'))
eq_(badge.title, doc.find('.badge .title').text())
eq_(badge.description, doc.find('.badge .description').text())
# Now, take a look at the JSON format
url = reverse('badger.detail_json', args=(badge.slug, ))
r = self.client.get(url, follow=True)
data = simplejson.loads(r.content)
eq_(badge.title, data['name'])
eq_(badge.description, data['description'])
eq_('http://testserver%s' % badge.get_absolute_url(),
data['criteria'])