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


Python test_models.save_valid_submission函数代码示例

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


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

示例1: test_make_unique_slug

 def test_make_unique_slug(self):
     """
     Ensure that unique slugs are generated even from titles whose
     first 50 characters are identical.
     
     """
     s = save_valid_submission("This is a really long title whose only purpose in life is to be longer than fifty characters")
     s2 = save_valid_submission("This is a really long title whose only purpose in life is to be longer than fifty characters and not the same as the first title")
     s3 = save_valid_submission("This is a really long title whose only purpose in life is to be longer than fifty characters and not the same as the first or second title")
     ok_(s.slug != s2.slug and s.slug != s3.slug and s2.slug != s3.slug)
开发者ID:LucianU,项目名称:kuma,代码行数:10,代码来源:test_views.py

示例2: test_derby_after_deadline

 def test_derby_after_deadline(self):
     s = save_valid_submission("hello world")
     closed_dt = datetime.date.today() - datetime.timedelta(days=32)
     s.taggit_tags.set_ns("challenge:", closed_dt.strftime("%Y:%B").lower())
     form = SubmissionEditForm(instance=s)
     assert "demo_package" not in form.fields
     assert "challenge_tags" not in form.fields
开发者ID:craigcook,项目名称:kuma,代码行数:7,代码来源:test_views.py

示例3: test_challenge_closed_model

 def test_challenge_closed_model(self):
     s = save_valid_submission("hellow world")
     assert not s.challenge_closed()
     s.taggit_tags.set_ns("challenge:", make_challenge_tag())
     assert not s.challenge_closed()
     closed_dt = datetime.date.today() - datetime.timedelta(days=32)
     s.taggit_tags.set_ns("challenge:", closed_dt.strftime("%Y:%B").lower())
     assert s.challenge_closed()
开发者ID:craigcook,项目名称:kuma,代码行数:8,代码来源:test_views.py

示例4: test_unicode

 def test_unicode(self):
     """
     Unicode characters in the summary or description doesn't brick the feed
     """
     s = save_valid_submission("ΦOTOS ftw", "ΦOTOS ΦOTOS ΦOTOS")
     s.featured = 1
     s.save()
     r = self.client.get(reverse("demos_feed_featured", args=["json"]))
     ok_(r.status_code == 200)
开发者ID:craigcook,项目名称:kuma,代码行数:9,代码来源:test_views.py

示例5: test_detail

    def test_detail(self):
        s = save_valid_submission("hello world")

        url = reverse("demos_detail", args=[s.slug])
        r = self.client.get(url)
        d = pq(r.content)
        eq_(s.title, d("h1.page-title").text())
        edit_link = d("ul.manage a.edit")
        assert not edit_link
开发者ID:craigcook,项目名称:kuma,代码行数:9,代码来源:test_views.py

示例6: test_edit_invalid

 def test_edit_invalid(self):
     s = save_valid_submission()
     edit_url = reverse("demos_edit", args=[s.slug])
     r = self.client.post(edit_url, data=dict())
     d = pq(r.content)
     assert d("form#demo-submit")
     assert d("li#field_title ul.errorlist")
     assert d("li#field_summary ul.errorlist")
     assert d("li#field_license_name ul.errorlist")
开发者ID:craigcook,项目名称:kuma,代码行数:9,代码来源:test_views.py

示例7: test_detail_censored

    def test_detail_censored(self):
        s = save_valid_submission('hello world')
        s.censored = True
        s.save()

        url = reverse('demos_detail', args=[s.slug])
        r = self.client.get(url)
        d = pq(r.content)
        eq_('Permission Denied', d('h1.page-title').text())
开发者ID:tantek,项目名称:kuma,代码行数:9,代码来源:test_views.py

示例8: test_detail_censored_url

    def test_detail_censored_url(self):
        s = save_valid_submission("hello world")
        s.censored = True
        s.censored_url = "http://developer.mozilla.org"
        s.save()

        url = reverse("demos_detail", args=[s.slug])
        r = self.client.get(url)
        eq_(302, r.status_code)
        eq_("http://developer.mozilla.org", r["Location"])
开发者ID:craigcook,项目名称:kuma,代码行数:10,代码来源:test_views.py

示例9: test_derby_tag_saving

    def test_derby_tag_saving(self):
        """
        There's some tricky bits in the handling of editing and saving
        challenge tags; this test just exercises a cycle of edit/save
        a couple times in a row to make sure we don't go foul in
        there.

        """
        s = save_valid_submission("hello world")
        closed_dt = datetime.date.today() - datetime.timedelta(days=32)
        s.taggit_tags.set_ns("challenge:", closed_dt.strftime("%Y:%B").lower())
        edit_url = reverse("demos_edit", args=[s.slug])
        r = self.client.get(edit_url)
        eq_(r.status_code, 200)

        r = self.client.post(
            edit_url,
            data=dict(
                title=s.title,
                summary="This is a test demo submission",
                description="Some description goes here",
                tech_tags=("tech:audio", "tech:video", "tech:websockets"),
                license_name="gpl",
                accept_terms="1",
            ),
        )

        eq_(302, r.status_code)
        assert "Location" in r
        assert s.slug in r["Location"]

        r = self.client.get(edit_url)
        eq_(r.status_code, 200)

        r = self.client.post(
            edit_url,
            data=dict(
                title=s.title,
                summary="This is a test demo submission",
                description="Some description goes here",
                tech_tags=("tech:audio", "tech:video", "tech:websockets"),
                license_name="gpl",
                accept_terms="1",
            ),
        )

        eq_(302, r.status_code)
        assert "Location" in r
        assert s.slug in r["Location"]

        r = self.client.get(edit_url)
        eq_(r.status_code, 200)
开发者ID:craigcook,项目名称:kuma,代码行数:52,代码来源:test_views.py

示例10: test_edit_no_tags

 def test_edit_no_tags(self):
     s = save_valid_submission('hello world')
     edit_url = reverse('demos_edit', args=[s.slug])
     r = self.client.post(edit_url, data=dict(
         title=s.title,
         summary='This is a test edit',
         description='Some description goes here',
         license_name='gpl',
         accept_terms='1',
     ))
     eq_(r.status_code, 302)
     r = self.client.get(edit_url)
     eq_(r.status_code, 200)
开发者ID:trinaldi,项目名称:kuma,代码行数:13,代码来源:test_views.py

示例11: test_creator_can_edit

    def test_creator_can_edit(self):
        s = save_valid_submission("hello world")

        url = reverse("demos_detail", args=[s.slug])
        r = self.client.get(url)
        d = pq(r.content)
        edit_link = d("ul#demo-manage a.edit")
        assert edit_link
        edit_url = reverse("demos_edit", args=[s.slug], locale="en-US")
        eq_(edit_url, edit_link.attr("href"))

        r = self.client.get(edit_url)
        assert pq(r.content)("form#demo-submit")
        eq_("Save changes", pq(r.content)('p.fm-submit button[type="submit"]').text())
开发者ID:craigcook,项目名称:kuma,代码行数:14,代码来源:test_views.py

示例12: test_long_slug

    def test_long_slug(self):
        """
        A title longer than 50 characters should truncate to a
        50-character slug during (python-level) save, not on DB
        insertion, so that anything that wants the slug to build a URL
        has the value that actually ends up in the DB.

        """
        s = save_valid_submission("AudioVisualizer for Alternative Music Notation Systems")
        s.taggit_tags.set_ns("tech:", "javascript")
        s.save()
        ok_(len(s.slug) == 50)
        r = self.client.get(reverse("demos.views.detail", args=(s.slug,)))
        ok_(r.status_code == 200)
开发者ID:craigcook,项目名称:kuma,代码行数:14,代码来源:test_views.py

示例13: test_edit_with_challenge_tag

 def test_edit_with_challenge_tag(self):
     s = save_valid_submission('hello world')
     edit_url = reverse('demos_edit', args=[s.slug])
     r = self.client.post(edit_url, data=dict(
         title=s.title,
         summary='This is a test edit',
         description='Some description goes here',
         tech_tags=('tech:audio',),
         challenge_tags=parse_tags(constance.config.DEMOS_DEVDERBY_CHALLENGE_CHOICE_TAGS)[0],
         license_name='gpl',
         accept_terms='1',
     ))
     eq_(r.status_code, 302)
     r = self.client.get(edit_url)
     eq_(r.status_code, 200)
开发者ID:trinaldi,项目名称:kuma,代码行数:15,代码来源:test_views.py

示例14: test_creator_can_edit

    def test_creator_can_edit(self):
        s = save_valid_submission('hello world')

        url = reverse('demos_detail', args=[s.slug])
        r = self.client.get(url)
        d = pq(r.content)
        edit_link = d('ul#demo-manage a.edit')
        assert edit_link
        edit_url = reverse('demos_edit', args=[s.slug])
        eq_(edit_url, edit_link.attr("href"))

        r = self.client.get(edit_url)
        assert pq(r.content)('form#demo-submit')
        eq_('Save changes',
            pq(r.content)('p.fm-submit button[type="submit"]').text())
开发者ID:tantek,项目名称:kuma,代码行数:15,代码来源:test_views.py

示例15: test_edit_no_tags

 def test_edit_no_tags(self):
     s = save_valid_submission("hello world")
     edit_url = reverse("demos_edit", args=[s.slug])
     r = self.client.post(
         edit_url,
         data=dict(
             title=s.title,
             summary="This is a test edit",
             description="Some description goes here",
             license_name="gpl",
             accept_terms="1",
         ),
     )
     eq_(r.status_code, 302)
     r = self.client.get(edit_url)
     eq_(r.status_code, 200)
开发者ID:craigcook,项目名称:kuma,代码行数:16,代码来源:test_views.py


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