• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.doc_rev函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wiki.tests.doc_rev函数的典型用法代码示例。如果您正苦于以下问题:Python doc_rev函数的具体用法?Python doc_rev怎么用?Python doc_rev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_raw_section_source

    def test_raw_section_source(self):
        """The raw source for a document section can be requested"""
        client = LocalizingClient()
        client.login(username='admin', password='testpass')
        d, r = doc_rev("""
            <h1 id="s1">Head 1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">Head 2</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s3">Head 3</h1>
            <p>test</p>
            <p>test</p>
        """)
        expected = """
            <h1 id="s2">Head 2</h1>
            <p>test</p>
            <p>test</p>
        """
        response = client.get('%s?section=s2&raw=true' %
                              reverse('wiki.document', args=[d.slug]))
        eq_(normalize_html(expected), 
            normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:26,代码来源:test_views.py


示例2: test_form_loaded_with_section

    def test_form_loaded_with_section(self):
        """RevisionForm given section_id should load initial content for only
        one section"""
        d, r = doc_rev(
            """
            <h1 id="s1">s1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">s2</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s3">s3</h1>
            <p>test</p>
            <p>test</p>
        """
        )
        expected = """
            <h1 id="s2">s2</h1>
            <p>test</p>
            <p>test</p>
        """
        rev_form = RevisionForm(instance=r, section_id="s2")
        eq_(normalize_html(expected), normalize_html(rev_form.initial["content"]))
开发者ID:Boldewyn,项目名称:kuma,代码行数:25,代码来源:test_forms.py


示例3: setUp

 def setUp(self):
     super(DeferredRenderingTests, self).setUp()
     self.rendered_content = 'THIS IS RENDERED'
     self.raw_content = 'THIS IS NOT RENDERED CONTENT'
     self.d1, self.r1 = doc_rev('Doc 1')
     constance.config.KUMA_DOCUMENT_RENDER_TIMEOUT = 600.0
     constance.config.KUMA_DOCUMENT_FORCE_DEFERRED_TIMEOUT = 7.0
开发者ID:swznd,项目名称:kuma,代码行数:7,代码来源:test_models.py


示例4: test_redirect_suppression

 def test_redirect_suppression(self):
     """The document view shouldn't redirect when passed redirect=no."""
     redirect, _ = doc_rev('REDIRECT [[http://smoo/]]')
     response = self.client.get(
                    redirect.get_absolute_url() + '?redirect=no',
                    follow=True)
     self.assertContains(response, 'REDIRECT ')
开发者ID:Uwanja,项目名称:kitsune,代码行数:7,代码来源:test_views.py


示例5: test_raw_with_editing_links_source

    def test_raw_with_editing_links_source(self):
        """The raw source for a document can be requested, with section editing
        links"""
        client = LocalizingClient()
        client.login(username='admin', password='testpass')
        d, r = doc_rev("""
            <h1 id="s1">Head 1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">Head 2</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s3">Head 3</h1>
            <p>test</p>
            <p>test</p>
        """)
        expected = """
            <h1 id="s1"><a class="edit-section" data-section-id="s1" data-section-src-url="/en-US/docs/%(slug)s?raw=true&amp;section=s1" href="/en-US/docs/%(slug)s$edit?section=s1&amp;edit_links=true" title="Edit section">Edit</a>Head 1</h1>
            <p>test</p>
            <p>test</p>
            <h1 id="s2"><a class="edit-section" data-section-id="s2" data-section-src-url="/en-US/docs/%(slug)s?raw=true&amp;section=s2" href="/en-US/docs/%(slug)s$edit?section=s2&amp;edit_links=true" title="Edit section">Edit</a>Head 2</h1>
            <p>test</p>
            <p>test</p>
            <h1 id="s3"><a class="edit-section" data-section-id="s3" data-section-src-url="/en-US/docs/%(slug)s?raw=true&amp;section=s3" href="/en-US/docs/%(slug)s$edit?section=s3&amp;edit_links=true" title="Edit section">Edit</a>Head 3</h1>
            <p>test</p>
            <p>test</p>
        """ % {'slug': d.slug}
        response = client.get('%s?raw=true&edit_links=true' %
                              reverse('wiki.document', args=[d.slug]))
        eq_(normalize_html(expected), 
            normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:33,代码来源:test_views.py


示例6: test_form_save_section

    def test_form_save_section(self):
        d, r = doc_rev(
            """
            <h1 id="s1">s1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">s2</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s3">s3</h1>
            <p>test</p>
            <p>test</p>
        """
        )
        replace_content = """
            <h1 id="s2">New stuff</h1>
            <p>new stuff</p>
        """
        expected = """
            <h1 id="s1">s1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">New stuff</h1>
            <p>new stuff</p>

            <h1 id="s3">s3</h1>
            <p>test</p>
            <p>test</p>
        """
        rev_form = RevisionForm({"content": replace_content}, instance=r, section_id="s2")
        new_rev = rev_form.save(r.creator, d)
        eq_(normalize_html(expected), normalize_html(new_rev.content))
开发者ID:Boldewyn,项目名称:kuma,代码行数:35,代码来源:test_forms.py


示例7: test_form_onload_attr_filter

 def test_form_onload_attr_filter(self):
     """RevisionForm should strip out any harmful onload attributes from
     input markup"""
     d, r = doc_rev("""
         <svg><circle onload=confirm(3)>
     """)
     rev_form = RevisionForm(instance=r)
     ok_('onload' not in rev_form.initial['content'])
开发者ID:Arveti,项目名称:kuma,代码行数:8,代码来源:test_forms.py


示例8: test_approved_revision_updates_html

    def test_approved_revision_updates_html(self):
        """Creating an approved revision updates document.html"""
        d, _ = doc_rev("Replace document html")

        assert "Replace document html" in d.html, '"Replace document html" not in %s' % d.html

        # Creating another approved revision replaces it again
        r = revision(document=d, content="Replace html again", is_approved=True)
        r.save()

        assert "Replace html again" in d.html, '"Replace html again" not in %s' % d.html
开发者ID:atopal,项目名称:kitsune,代码行数:11,代码来源:test_models.py


示例9: test_unapproved_revision_not_updates_html

    def test_unapproved_revision_not_updates_html(self):
        """Creating an unapproved revision does not update document.html"""
        d, _ = doc_rev('Here to stay')

        assert 'Here to stay' in d.html, '"Here to stay" not in %s' % d.html

        # Creating another approved revision keeps initial content
        r = revision(document=d, content='Fail to replace html')
        r.save()

        assert 'Here to stay' in d.html, '"Here to stay" not in %s' % d.html
开发者ID:Akamad007,项目名称:kitsune,代码行数:11,代码来源:test_models.py


示例10: test_retitling

 def test_retitling(self):
     """When the title of an article is edited, a redirect is made."""
     # Not testing slug changes separately; the model tests cover those plus
     # slug+title changes. If title changes work in the view, the rest
     # should also.
     new_title = "Some New Title"
     d, r = doc_rev()
     old_title = d.title
     data = new_document_data()
     data.update({"title": new_title, "slug": d.slug, "form": "doc"})
     self.client.post(reverse("wiki.edit_document", args=[d.slug]), data)
     eq_(new_title, Document.uncached.get(slug=d.slug).title)
     assert Document.uncached.get(title=old_title).redirect_url()
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:13,代码来源:test_views.py


示例11: test_changing_products

 def test_changing_products(self):
     """Changing products works as expected."""
     d, r = doc_rev()
     data = new_document_data()
     data.update({'products': ['desktop', 'sync'],
                  'form': 'doc'})
     self.client.post(reverse('wiki.edit_document', args=[d.slug]), data)
     tags_eq(d, ['desktop', 'sync'])
     data.update({'products': ['mobile'],
                  'form': 'doc'})
     self.client.post(reverse('wiki.edit_document', args=[data['slug']]),
                      data)
     tags_eq(d, ['mobile'])
开发者ID:erikrose,项目名称:kitsune,代码行数:13,代码来源:test_views.py


示例12: test_changing_products

 def test_changing_products(self):
     """Changing products works as expected."""
     client = LocalizingClient()
     client.login(username='admin', password='testpass')
     d, r = doc_rev()
     data = new_document_data()
     data.update({'products': ['desktop', 'sync'],
                  'form': 'doc'})
     client.post(reverse('wiki.edit_document', args=[d.slug]), data)
     tags_eq(d, ['desktop', 'sync'])
     data.update({'products': ['mobile'],
                  'form': 'doc'})
     client.post(reverse('wiki.edit_document', args=[data['slug']]), data)
     tags_eq(d, ['mobile'])
开发者ID:fox2mike,项目名称:kitsune,代码行数:14,代码来源:test_views.py


示例13: test_retitling_ignored_for_iframe

 def test_retitling_ignored_for_iframe(self):
     """When the title of an article is edited in an iframe, the change is
     ignored."""
     client = LocalizingClient()
     client.login(username='admin', password='testpass')
     new_title = 'Some New Title'
     d, r = doc_rev()
     old_title = d.title
     data = new_document_data()
     data.update({'title': new_title,
                  'slug': d.slug,
                  'form': 'rev'})
     client.post('%s?iframe=1' % reverse('wiki.edit_document', args=[d.slug]), data)
     eq_(old_title, Document.uncached.get(slug=d.slug).title)
     assert "REDIRECT" not in Document.uncached.get(title=old_title).html
开发者ID:pmclanahan,项目名称:kuma,代码行数:15,代码来源:test_views.py


示例14: test_raw_section_edit

    def test_raw_section_edit(self):
        client = LocalizingClient()
        client.login(username='admin', password='testpass')
        d, r = doc_rev("""
            <h1 id="s1">Head 1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">Head 2</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s3">Head 3</h1>
            <p>test</p>
            <p>test</p>
        """)
        replace = """
            <h1 id="s2">Replace</h1>
            <p>replace</p>
        """
        expected = """
            <h1 id="s2">Replace</h1>
            <p>replace</p>
        """
        response = client.post('%s?section=s2&raw=true' %
                               reverse('wiki.edit_document', args=[d.slug]),
                               {"form": "rev",
                                "content": replace},
                               follow=True)
        eq_(normalize_html(expected), 
            normalize_html(response.content))

        expected = """
            <h1 id="s1">Head 1</h1>
            <p>test</p>
            <p>test</p>

            <h1 id="s2">Replace</h1>
            <p>replace</p>

            <h1 id="s3">Head 3</h1>
            <p>test</p>
            <p>test</p>
        """
        response = client.get('%s?raw=true' %
                               reverse('wiki.document', args=[d.slug]))
        eq_(normalize_html(expected), 
            normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:48,代码来源:test_views.py


示例15: test_show_toc

    def test_show_toc(self):
        """Setting show_toc appropriately affects the Document's
        show_toc property."""
        d, r = doc_rev('Toggle table of contents.')
        assert r.show_toc
        assert d.show_toc

        r = revision(document=d, content=r.content, show_toc=False,
                     is_approved=True)
        r.save()
        assert not d.show_toc

        r = revision(document=d, content=r.content, show_toc=True,
                     is_approved=True)
        r.save()
        assert d.show_toc
开发者ID:swznd,项目名称:kuma,代码行数:16,代码来源:test_models.py


示例16: test_retitling

 def test_retitling(self):
     """When the title of an article is edited, a redirect is made."""
     # Not testing slug changes separately; the model tests cover those plus
     # slug+title changes. If title changes work in the view, the rest
     # should also.
     client = LocalizingClient()
     client.login(username='admin', password='testpass')
     new_title = 'Some New Title'
     d, r = doc_rev()
     old_title = d.title
     data = new_document_data()
     data.update({'title': new_title,
                  'slug': d.slug,
                  'form': 'doc'})
     client.post(reverse('wiki.edit_document', args=[d.slug]), data)
     eq_(new_title, Document.uncached.get(slug=d.slug).title)
     assert Document.uncached.get(title=old_title).redirect_url()
开发者ID:fox2mike,项目名称:kitsune,代码行数:17,代码来源:test_views.py


示例17: test_changing_metadata

 def test_changing_metadata(self):
     """Changing metadata works as expected."""
     client = LocalizingClient()
     client.login(username='admin', password='testpass')
     d, r = doc_rev()
     data = new_document_data()
     data.update({'firefox_versions': [1, 2, 3],
                  'operating_systems': [1, 3],
                  'form': 'doc'})
     client.post(reverse('wiki.edit_document', args=[d.slug]), data)
     eq_(3, d.firefox_versions.count())
     eq_(2, d.operating_systems.count())
     data.update({'firefox_versions': [1, 2],
                  'operating_systems': [2],
                  'form': 'doc'})
     client.post(reverse('wiki.edit_document', args=[data['slug']]), data)
     eq_(2, d.firefox_versions.count())
     eq_(1, d.operating_systems.count())
开发者ID:fwenzel,项目名称:kitsune,代码行数:18,代码来源:test_views.py


示例18: test_revert

    def test_revert(self):
        """Reverting to a specific revision."""
        d, r = doc_rev('Test reverting')
        old_id = r.id

        time.sleep(1)

        r2 = revision(document=d, title='Test reverting',
                      content='An edit to revert',
                      comment='This edit gets reverted',
                      is_approved=True)
        r.save()

        time.sleep(1)

        reverted = d.revert(r, r.creator)
        ok_('Revert to' in reverted.comment)
        ok_('Test reverting' == reverted.content)
        ok_(old_id != reverted.id)
开发者ID:swznd,项目名称:kuma,代码行数:19,代码来源:test_models.py


示例19: test_revision_tags

    def test_revision_tags(self):
        """Change tags on Document by creating Revisions"""
        d, _ = doc_rev('Sample document')

        eq_(0, Document.objects.filter(tags__name='foo').count())
        eq_(0, Document.objects.filter(tags__name='alpha').count())

        r = revision(document=d, content='Update to document',
                     is_approved=True, tags="foo, bar, baz")
        r.save()

        eq_(1, Document.objects.filter(tags__name='foo').count())
        eq_(0, Document.objects.filter(tags__name='alpha').count())

        r = revision(document=d, content='Another update',
                     is_approved=True, tags="alpha, beta, gamma")
        r.save()

        eq_(0, Document.objects.filter(tags__name='foo').count())
        eq_(1, Document.objects.filter(tags__name='alpha').count())
开发者ID:swznd,项目名称:kuma,代码行数:20,代码来源:test_models.py


示例20: test_changing_products

    def test_changing_products(self):
        """Changing products works as expected."""
        d, r = doc_rev()
        prod_desktop = product(title=u"desktop", save=True)
        prod_mobile = product(title=u"mobile", save=True)

        data = new_document_data()
        data.update({"products": [prod_desktop.id, prod_mobile.id], "title": d.title, "slug": d.slug, "form": "doc"})
        self.client.post(reverse("wiki.edit_document", args=[d.slug]), data)

        eq_(
            sorted(Document.uncached.get(slug=d.slug).products.values_list("id", flat=True)),
            sorted([prod.id for prod in [prod_desktop, prod_mobile]]),
        )

        data.update({"products": [prod_desktop.id], "form": "doc"})
        self.client.post(reverse("wiki.edit_document", args=[data["slug"]]), data)
        eq_(
            sorted(Document.uncached.get(slug=d.slug).products.values_list("id", flat=True)),
            sorted([prod.id for prod in [prod_desktop]]),
        )
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:21,代码来源:test_views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.document函数代码示例发布时间:2022-05-26
下一篇:
Python wiki_tags.get_content_snippet函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap