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


Python Publish.query方法代码示例

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


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

示例1: test_already_published

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:27,代码来源:test_publish.py

示例2: test_bad_source

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:34,代码来源:test_publish.py

示例3: test_no_content

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:9,代码来源:test_publish.py

示例4: test_facebook_comment_and_like_disabled

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:28,代码来源:test_publish.py

示例5: test_type_not_implemented

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:10,代码来源:test_publish.py

示例6: test_source_missing_mf2

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:11,代码来源:test_publish.py

示例7: test_rsvp_without_in_reply_to

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:11,代码来源:publish_test.py

示例8: test_source_with_multiple_domains

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
 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,代码行数:11,代码来源:test_publish.py

示例9: test_source_with_multiple_domains

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:12,代码来源:publish_test.py

示例10: test_interactive_oauth_decline

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:12,代码来源:test_publish.py

示例11: test_returned_type_overrides

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:13,代码来源:test_publish.py

示例12: test_interactive_no_state

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:13,代码来源:test_publish.py

示例13: _check_entity

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
 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,代码行数:14,代码来源:test_publish.py

示例14: test_embedded_type_not_implemented

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:14,代码来源:publish_test.py

示例15: test_embedded_type_not_implemented

# 需要导入模块: from models import Publish [as 别名]
# 或者: from models.Publish import query [as 别名]
  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,代码行数:14,代码来源:test_publish.py


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