Beispiel #1
0
 def test_new(self):
   b = Blogger.new(self.handler, auth_entity=self.auth_entity)
   self.assertEquals(self.auth_entity.key, b.auth_entity)
   self.assertEquals('name', b.name)
   self.assertEquals(['http://my.blawg/'], b.domain_urls)
   self.assertEquals(['my.blawg'], b.domains)
   self.assertEquals('http://pic', b.picture)
Beispiel #2
0
 def test_new(self):
   b = Blogger.new(self.handler, auth_entity=self.auth_entity)
   self.assertEquals(self.auth_entity.key, b.auth_entity)
   self.assertEquals('name', b.name)
   self.assertEquals(['http://my.blawg/'], b.domain_urls)
   self.assertEquals(['my.blawg'], b.domains)
   self.assertEquals('http://pic', b.picture)
Beispiel #3
0
  def test_create_comment(self):
    self.expect_get_posts()
    self.client.add_comment('111', '222', '<a href="http://who">who</a>: foo bar'
                            ).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', 'who', 'http://who',
                            'foo bar', client=self.client)
    self.assert_equals({'id': '333', 'response': '<foo></foo>'}, resp)
Beispiel #4
0
  def test_create_comment(self):
    self.expect_get_posts()
    self.client.add_comment('111', '222', '<a href="http://who">who</a>: foo bar'
                            ).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', 'who', 'http://who',
                            'foo bar', client=self.client)
    self.assert_equals({'id': '333', 'response': '<foo></foo>'}, resp)
Beispiel #5
0
  def test_create_too_long_comment(self):
    """Blogger caps totally HTML comment length at 4096 chars."""
    self.expect_get_posts()
    self.client.add_comment(
      '111', '222', u'<a href="http://who">Degenève</a>: foo Degenève bar'
      ).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', u'Degenève', 'http://who',
                            u'foo Degenève bar', client=self.client)
Beispiel #6
0
  def test_create_comment_gives_up_on_internal_error_bX2i87au(self):
    # see https://github.com/snarfed/bridgy/issues/175
    self.expect_get_posts()
    self.client.add_comment('111', '222', '<a href="http://who">who</a>: foo bar'
                            ).AndRaise(RequestError('500, Internal error: bX-2i87au'))
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', 'who', 'http://who',
                            'foo bar', client=self.client)
    # the key point is that create_comment doesn't raise an exception
    self.assert_equals({'error': '500, Internal error: bX-2i87au'}, resp)
Beispiel #7
0
  def test_create_comment_gives_up_on_internal_error_bX2i87au(self):
    # see https://github.com/snarfed/bridgy/issues/175
    self.expect_get_posts()
    self.client.add_comment('111', '222', '<a href="http://who">who</a>: foo bar'
                            ).AndRaise(RequestError('500, Internal error: bX-2i87au'))
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', 'who', 'http://who',
                            'foo bar', client=self.client)
    # the key point is that create_comment doesn't raise an exception
    self.assert_equals({'error': '500, Internal error: bX-2i87au'}, resp)
Beispiel #8
0
  def test_create_too_long_comment(self):
    """Blogger caps HTML comment length at 4096 chars."""
    self.expect_get_posts()
    self.client.add_comment(
      '111', '222', u'<a href="http://who">Degenève</a>: foo Degenève bar'
      ).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', u'Degenève', 'http://who',
                            u'foo Degenève bar', client=self.client)
    self.assert_equals({'id': '333', 'response': '<foo></foo>'}, resp)
Beispiel #9
0
  def test_create_comment_with_unicode_chars(self):
    # TODO: this just checks the arguments passed to client.add_comment(). we
    # should test that the blogger client itself encodes as UTF-8.
    self.expect_get_posts()

    prefix = u'<a href="http://who">Degenève</a>: '
    content = prefix + 'x' * (blogger.MAX_COMMENT_LENGTH - len(prefix) - 3) + '...'
    self.client.add_comment('111', '222', content).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', u'Degenève', 'http://who',
                            'x' * blogger.MAX_COMMENT_LENGTH, client=self.client)
Beispiel #10
0
  def test_create_comment_with_unicode_chars(self):
    # TODO: this just checks the arguments passed to client.add_comment(). we
    # should test that the blogger client itself encodes as UTF-8.
    self.expect_get_posts()

    prefix = u'<a href="http://who">Degenève</a>: '
    content = prefix + 'x' * (blogger.MAX_COMMENT_LENGTH - len(prefix) - 3) + '...'
    self.client.add_comment('111', '222', content).AndReturn(self.comment)
    self.mox.ReplayAll()

    b = Blogger.new(self.handler, auth_entity=self.auth_entity)
    resp = b.create_comment('http://blawg/path/to/post', u'Degenève', 'http://who',
                            'x' * blogger.MAX_COMMENT_LENGTH, client=self.client)
    self.assert_equals({'id': '333', 'response': '<foo></foo>'}, resp)
Beispiel #11
0
 def test_new_no_blogs(self):
   self.auth_entity.blog_hostnames = []
   self.assertIsNone(Blogger.new(self.handler, auth_entity=self.auth_entity))
   self.assertIn('Blogger blog not found', next(iter(self.handler.messages)))
Beispiel #12
0
 def test_feed_url(self):
   self.assertEquals(
     'http://my.blawg/feeds/posts/default',
     Blogger.new(self.handler, auth_entity=self.auth_entity).feed_url())
Beispiel #13
0
 def test_new_no_blogs(self):
   self.auth_entity.blog_hostnames = []
   self.assertIsNone(Blogger.new(self.handler, auth_entity=self.auth_entity))
   self.assertIn('Blogger blog not found', next(iter(self.handler.messages)))
Beispiel #14
0
 def test_feed_url(self):
   self.assertEquals(
     'http://my.blawg/feeds/posts/default',
     Blogger.new(self.handler, auth_entity=self.auth_entity).feed_url())
Beispiel #15
0
 def test_new_no_blogs(self):
   self.auth_entity.blog_hostnames = []
   with app.test_request_context():
     self.assertIsNone(Blogger.new(auth_entity=self.auth_entity))
     self.assertIn('Blogger blog not found', get_flashed_messages()[0])