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

Python models.Publish类代码示例

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

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



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

示例1: test_already_published

  def test_already_published(self):
    """We shouldn't allow duplicating an existing, *completed* publish."""
    page = PublishedPage(id='http://foo.com/bar')

    # these are all fine
    Publish(parent=page.key, source=self.source.key, status='new').put()
    Publish(parent=page.key, source=self.source.key, status='failed').put()
    Publish(parent=page.key, source=self.source.key, status='complete',
            type='preview').put()

    for i in range(2):
      self.expect_requests_get('http://foo.com/bar', self.post_html % 'foo')
    self.mox.ReplayAll()

    # first attempt should work
    self.assert_created('foo - http://foo.com/bar')
    self.assertEquals(4, Publish.query().count())
    self.assertEquals(2, Publish.query(Publish.status == 'complete').count())

    # now that there's a complete Publish entity, more attempts should fail
    self.assert_error("Sorry, you've already published that page")
    # try again to test for a bug we had where a second try would succeed
    self.assert_error("Sorry, you've already published that page")
    # should still be able to preview though
    self.assert_success('preview of foo', preview=True)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:25,代码来源:test_publish.py


示例2: test_no_content

  def test_no_content(self):
    self.expect_requests_get('http://foo.com/bar',
                             '<article class="h-entry h-as-note"></article>')
    self.mox.ReplayAll()

    self.assert_error('or no content was found')
    self.assertEquals('failed', Publish.query().get().status)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:7,代码来源:test_publish.py


示例3: test_bad_source

  def test_bad_source(self):
    # no source
    self.source.key.delete()
    self.assert_error('Could not find <b>FakeSource</b> account for <b>foo.com</b>.')

    # source without publish feature
    self.source.features = ['listen']
    self.source.put()
    msg = 'Publish is not enabled'
    self.assert_error(msg)

    # status disabled
    self.source.features = ['publish']
    self.source.status = 'disabled'
    self.source.put()
    self.assert_error(msg)

    # two bad sources with same domain
    source_2 = self.source = testutil.FakeSource(id='z', **self.source.to_dict())
    source_2.status = 'enabled'
    source_2.features = ['listen']
    source_2.put()
    self.assert_error(msg)

    # one bad source, one good source, same domain. should automatically use the
    # good source.
    source_2.features.append('publish')
    source_2.put()
    self.expect_requests_get('http://foo.com/bar', self.post_html % 'xyz')
    self.mox.ReplayAll()
    self.assert_created('xyz - http://foo.com/bar')
    self.assertEquals(source_2.key, Publish.query().get().source)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:32,代码来源:test_publish.py


示例4: test_facebook_comment_and_like_disabled

  def test_facebook_comment_and_like_disabled(self):
    self.source = facebook.FacebookPage(id='789', features=['publish'],
                                        domains=['mr.x'])
    self.source.put()

    self.expect_requests_get('http://mr.x/like', """
    <article class="h-entry">
      <a class="u-like-of" href="http://facebook.com/789/posts/456">liked this</a>
      <a href="http://localhost/publish/facebook"></a>
    </article>""")
    self.expect_requests_get('http://mr.x/comment', """
    <article class="h-entry">
      <a class="u-in-reply-to" href="http://facebook.com/789/posts/456">reply</a>
      <a href="http://localhost/publish/facebook"></a>
    </article>""")
    self.mox.ReplayAll()

    self.assert_error('Facebook comments and likes are no longer supported',
                      source='http://mr.x/like',
                      target='https://brid.gy/publish/facebook')
    self.assertEquals('failed', Publish.query().get().status)

    self.assert_error('Facebook comments and likes are no longer supported',
                      source='http://mr.x/comment',
                      target='https://brid.gy/publish/facebook',
                      preview=True)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:26,代码来源:test_publish.py


示例5: test_type_not_implemented

  def test_type_not_implemented(self):
    self.expect_requests_get('http://foo.com/bar',
                             '<article class="h-entry h-as-like"></article>')
    self.mox.ReplayAll()

    # FakeSource.create() raises NotImplementedError on likes
    self.assert_error('Cannot publish likes')
    self.assertEquals('failed', Publish.query().get().status)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:8,代码来源:test_publish.py


示例6: test_source_with_multiple_domains

 def test_source_with_multiple_domains(self):
   """Publish domain is second in source's domains list."""
   self.source.domains = ['baj.com', 'foo.com']
   self.source.domain_urls = ['http://baj.com/', 'http://foo.com/']
   self.source.put()
   self.expect_requests_get('http://foo.com/bar', self.post_html % 'xyz')
   self.mox.ReplayAll()
   self.assert_created('xyz - http://foo.com/bar')
   self.assertEquals(self.source.key, Publish.query().get().source)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:9,代码来源:test_publish.py


示例7: test_rsvp_without_in_reply_to

  def test_rsvp_without_in_reply_to(self):
    self.expect_requests_get('http://foo.com/bar', """
<article class="h-entry">
<p class="e-content">
<data class="p-rsvp" value="yes">I'm in!</data>
</p></article>""")
    self.mox.ReplayAll()
    self.assert_error("looks like an RSVP, but it's missing an in-reply-to link")
    self.assertEquals('failed', Publish.query().get().status)
开发者ID:notenoughneon,项目名称:bridgy,代码行数:9,代码来源:publish_test.py


示例8: test_source_missing_mf2

  def test_source_missing_mf2(self):
    self.expect_requests_get('http://foo.com/bar', '')
    self.mox.ReplayAll()
    self.assert_error('No microformats2 data found in http://foo.com/')

    self.assertTrue(PublishedPage.get_by_id('http://foo.com/bar'))
    publish = Publish.query().get()
    self.assertEquals('failed', publish.status)
    self.assertEquals(self.source.key, publish.source)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:9,代码来源:test_publish.py


示例9: test_interactive_oauth_decline

  def test_interactive_oauth_decline(self):
    self.auth_entity = None
    resp = self.get_response(interactive=True)
    self.assertEquals(302, resp.status_int)
    self.assertEquals(
      'http://localhost/fake/foo.com#!'
        'If you want to publish or preview, please approve the prompt.',
      urllib.unquote_plus(resp.headers['Location']))

    self.assertIsNone(Publish.query().get())
开发者ID:Maymanaf,项目名称:bridgy,代码行数:10,代码来源:test_publish.py


示例10: test_source_with_multiple_domains

  def test_source_with_multiple_domains(self):
    """Publish domain is second in source's domains list."""
    self.source.domains = ['baj.com', 'foo.com']
    self.source.domain_urls = ['http://baj.com/', 'http://foo.com/']
    self.source.put()
    self.expect_requests_get('http://foo.com/bar', """
<article class="h-entry"><p class="e-content">xyz</p></article>""")
    self.mox.ReplayAll()
    self.assert_success('xyz - http://foo.com/bar')
    self.assertEquals(self.source.key, Publish.query().get().source)
开发者ID:sanduhrs,项目名称:bridgy,代码行数:10,代码来源:publish_test.py


示例11: test_returned_type_overrides

  def test_returned_type_overrides(self):
    # FakeSource returns type 'post' when it sees 'rsvp'
    self.expect_requests_get('http://foo.com/bar', """
<article class="h-entry h-as-rsvp">
<p class="e-content">
<data class="p-rsvp" value="yes"></data>
<a class="u-in-reply-to" href="http://fa.ke/event"></a>
</p></article>""")
    self.mox.ReplayAll()
    self.assert_created('')
    self.assertEquals('post', Publish.query().get().type)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:11,代码来源:test_publish.py


示例12: test_interactive_no_state

  def test_interactive_no_state(self):
    """https://github.com/snarfed/bridgy/issues/449"""
    self.oauth_state = None
    resp = self.get_response(interactive=True)
    self.assertEquals(302, resp.status_int)
    self.assertEquals(
      'http://localhost/#!'
        'If you want to publish or preview, please approve the prompt.',
      urllib.unquote_plus(resp.headers['Location']))

    self.assertIsNone(Publish.query().get())
开发者ID:Maymanaf,项目名称:bridgy,代码行数:11,代码来源:test_publish.py


示例13: get_or_add_publish_entity

  def get_or_add_publish_entity(self, source_url):
    """Creates and stores Publish and (if necessary) PublishedPage entities.

    Args:
      source_url: string
    """
    page = PublishedPage.get_or_insert(source_url)
    entity = Publish.query(
      Publish.status == 'complete', Publish.type != 'preview',
      Publish.source == self.source.key,
      ancestor=page.key).get()

    if entity is None:
      entity = Publish(parent=page.key, source=self.source.key)
      if self.PREVIEW:
        entity.type = 'preview'
      entity.put()

    logging.debug('Publish entity: %s', entity.key.urlsafe())
    return entity
开发者ID:lcorbasson,项目名称:bridgy,代码行数:20,代码来源:publish.py


示例14: test_embedded_type_not_implemented

  def test_embedded_type_not_implemented(self):
    self.expect_requests_get('http://foo.com/bar', """
<article class="h-entry">
  <div class="p-like-of">
    foo <a class="u-url" href="http://url">bar</a>
  </div>
</article>""")
    self.mox.ReplayAll()

    # FakeSource.create() raises NotImplementedError on likes
    self.assert_error("FakeSource doesn't support type(s) like-of")
    self.assertEquals('failed', Publish.query().get().status)
开发者ID:notenoughneon,项目名称:bridgy,代码行数:12,代码来源:publish_test.py


示例15: _check_entity

 def _check_entity(self):
   self.assertTrue(PublishedPage.get_by_id('http://foo.com/bar'))
   publish = Publish.query().get()
   self.assertEquals(self.source.key, publish.source)
   self.assertEquals('complete', publish.status)
   self.assertEquals('post', publish.type)
   self.assertEquals('FakeSource post label', publish.type_label)
   expected_html = (self.post_html % 'foo') + self.backlink
   self.assertEquals(expected_html, publish.html)
   self.assertEquals({'id': 'fake id', 'url': 'http://fake/url',
                      'content': 'foo - http://foo.com/bar'},
                     publish.published)
开发者ID:singpolyma,项目名称:bridgy,代码行数:12,代码来源:test_publish.py


示例16: test_embedded_type_not_implemented

  def test_embedded_type_not_implemented(self):
    self.expect_requests_get('http://foo.com/bar', """
<article class="h-entry">
  <div class="p-like-of">
    foo <a class="u-url" href="http://url">bar</a>
  </div>
</article>""")
    self.mox.ReplayAll()

    # FakeSource.create() returns an error message for verb='like'
    self.assert_error("Cannot publish likes")
    self.assertEquals('failed', Publish.query().get().status)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:12,代码来源:test_publish.py


示例17: test_interactive_from_wrong_user_page

  def test_interactive_from_wrong_user_page(self):
    other_source = testutil.FakeSource.new(None).put()
    self.oauth_state['source_key'] = other_source.urlsafe()

    resp = self.get_response(interactive=True)
    self.assertEquals(302, resp.status_int)
    self.assertEquals(
      'http://localhost/fake/%s#!'
        'Please log into FakeSource as fake to publish that page.' %
        other_source.id(),
      urllib.unquote_plus(resp.headers['Location']))

    self.assertIsNone(Publish.query().get())
开发者ID:Maymanaf,项目名称:bridgy,代码行数:13,代码来源:test_publish.py


示例18: test_preview

  def test_preview(self):
    html = '<article class="h-entry"><p class="e-content">foo</p></article>'
    self.expect_requests_get('http://foo.com/bar', html)
    # make sure create() isn't called
    self.mox.StubOutWithMock(self.source.as_source, 'create', use_mock_anything=True)
    self.mox.ReplayAll()
    self.assert_success('preview of foo - http://foo.com/bar', preview=True)

    publish = Publish.query().get()
    self.assertEquals(self.source.key, publish.source)
    self.assertEquals('complete', publish.status)
    self.assertEquals('preview', publish.type)
    self.assertEquals(html, publish.html)
开发者ID:sanduhrs,项目名称:bridgy,代码行数:13,代码来源:publish_test.py


示例19: get_or_add_publish_entity

  def get_or_add_publish_entity(self, source_url):
    """Creates and stores :class:`models.Publish` entity.

    ...and if necessary, :class:`models.PublishedPage` entity.

    Args:
      source_url: string
    """
    page = PublishedPage.get_or_insert(native_str(source_url.encode('utf-8')))
    entity = Publish.query(
      Publish.status == 'complete', Publish.type != 'preview',
      Publish.source == self.source.key,
      ancestor=page.key).get()

    if entity is None:
      entity = Publish(parent=page.key, source=self.source.key)
      if self.PREVIEW:
        entity.type = 'preview'
      entity.put()

    logging.debug("Publish entity: '%s'", entity.key.urlsafe())
    return entity
开发者ID:snarfed,项目名称:bridgy,代码行数:22,代码来源:publish.py


示例20: test_preview

  def test_preview(self):
    html = self.post_html % 'foo'
    self.expect_requests_get('http://foo.com/bar', html)
    # make sure create() isn't called
    self.mox.StubOutWithMock(self.source.gr_source, 'create', use_mock_anything=True)
    self.mox.ReplayAll()
    self.assert_success('preview of foo', preview=True)

    publish = Publish.query().get()
    self.assertEquals(self.source.key, publish.source)
    self.assertEquals('complete', publish.status)
    self.assertEquals('preview', publish.type)
    self.assertEquals(html + self.backlink, publish.html)
开发者ID:Maymanaf,项目名称:bridgy,代码行数:13,代码来源:test_publish.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.QotdGame类代码示例发布时间:2022-05-27
下一篇:
Python models.Project类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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