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


Python tests.doc_rev函数代码示例

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


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


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