本文整理汇总了Python中zds.tutorialv2.factories.PublishableContentFactory.get_absolute_url_online方法的典型用法代码示例。如果您正苦于以下问题:Python PublishableContentFactory.get_absolute_url_online方法的具体用法?Python PublishableContentFactory.get_absolute_url_online怎么用?Python PublishableContentFactory.get_absolute_url_online使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zds.tutorialv2.factories.PublishableContentFactory
的用法示例。
在下文中一共展示了PublishableContentFactory.get_absolute_url_online方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LastTutorialsFeedRSSTest
# 需要导入模块: from zds.tutorialv2.factories import PublishableContentFactory [as 别名]
# 或者: from zds.tutorialv2.factories.PublishableContentFactory import get_absolute_url_online [as 别名]
#.........这里部分代码省略.........
bot = Group(name=overridden_zds_app['member']['bot_group'])
bot.save()
self.external = UserFactory(
username=overridden_zds_app['member']['external_account'],
password='anything')
self.beta_forum = ForumFactory(
pk=overridden_zds_app['forum']['beta_forum_id'],
category=CategoryFactory(position=1),
position_in_category=1) # ensure that the forum, for the beta versions, is created
self.licence = LicenceFactory()
self.subcategory = SubCategoryFactory()
self.user_author = ProfileFactory().user
self.user_staff = StaffProfileFactory().user
self.user_guest = ProfileFactory().user
# create a tutorial
self.tuto = PublishableContentFactory(type='TUTORIAL')
self.tuto.authors.add(self.user_author)
UserGalleryFactory(gallery=self.tuto.gallery, user=self.user_author, mode='W')
self.tuto.licence = self.licence
self.tuto.subcategory.add(self.subcategory)
self.tuto.save()
# fill it with one part, containing one chapter, containing one extract
self.tuto_draft = self.tuto.load_version()
self.part1 = ContainerFactory(parent=self.tuto_draft, db_object=self.tuto)
self.chapter1 = ContainerFactory(parent=self.part1, db_object=self.tuto)
self.extract1 = ExtractFactory(container=self.chapter1, db_object=self.tuto)
# then, publish it !
version = self.tuto_draft.current_version
self.published = publish_content(self.tuto, self.tuto_draft, is_major_update=True)
self.tuto.sha_public = version
self.tuto.sha_draft = version
self.tuto.public_version = self.published
self.tuto.save()
self.tutofeed = LastTutorialsFeedRSS()
def test_is_well_setup(self):
""" Test that base parameters are Ok """
self.assertEqual(self.tutofeed.link, '/tutoriels/')
reftitle = 'Tutoriels sur {}'.format(overridden_zds_app['site']['literal_name'])
self.assertEqual(self.tutofeed.title, reftitle)
refdescription = 'Les derniers tutoriels parus sur {}.'.format(overridden_zds_app['site']['literal_name'])
self.assertEqual(self.tutofeed.description, refdescription)
atom = LastTutorialsFeedATOM()
self.assertEqual(atom.subtitle, refdescription)
def test_get_items(self):
""" basic test sending back the tutorial """
ret = list(self.tutofeed.items())
self.assertEqual(ret[0].content, self.tuto)
def test_get_pubdate(self):
""" test the return value of pubdate """
ref = PublishedContent.objects.get(content__pk=self.tuto.pk).publication_date
tuto = list(self.tutofeed.items())[0]
ret = self.tutofeed.item_pubdate(item=tuto)
self.assertEqual(ret.date(), ref.date())
def test_get_title(self):
""" test the return value of title """
ref = self.tuto.title
tuto = list(self.tutofeed.items())[0]
ret = self.tutofeed.item_title(item=tuto)
self.assertEqual(ret, ref)
def test_get_description(self):
""" test the return value of description """
ref = self.tuto.description
tuto = list(self.tutofeed.items())[0]
ret = self.tutofeed.item_description(item=tuto)
self.assertEqual(ret, ref)
def test_get_author_name(self):
""" test the return value of author name """
ref = self.user_author.username
tuto = list(self.tutofeed.items())[0]
ret = self.tutofeed.item_author_name(item=tuto)
self.assertEqual(ret, ref)
def test_get_item_link(self):
""" test the return value of item link """
ref = self.tuto.get_absolute_url_online()
tuto = list(self.tutofeed.items())[0]
ret = self.tutofeed.item_link(item=tuto)
self.assertEqual(ret, ref)