Exemplo n.º 1
0
  def test_add_comment(self):
    self.mox.StubOutWithMock(wordpress, 'get_post_id')
    wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

    self.expect_xmlrpc_ok('wp.newComment', 999, '', '', 789,
                       author='me', author_url='http://me',
                       content=self.expected_content)
    self.mox.ReplayAll()
    self.site.add_comment(self.comments[0])
Exemplo n.º 2
0
  def test_add_comment_reformat(self):
    """<br /> in comments should be converted to <p />."""
    self.mox.StubOutWithMock(wordpress, 'get_post_id')
    wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

    self.comments[0].content = 'bar<br />foo'
    expected = 'bar<p />' + self.expected_content
    self.expect_xmlrpc_ok('wp.newComment', 999, '', '', 789,
                       author='me', author_url='http://me', content=expected)
    self.mox.ReplayAll()
    self.site.add_comment(self.comments[0])
Exemplo n.º 3
0
  def test_add_comment_passes_through_other_fault(self):
    self.mox.StubOutWithMock(wordpress, 'get_post_id')
    wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

    fault = xmlrpclib.Fault(500, 'other error')
    self.expect_xmlrpc('wp.newComment', 999, '', '', 789,
                       author='me', author_url='http://me',
                       content=self.expected_content,
                       ).AndRaise(fault)
    self.mox.ReplayAll()

    self.assertRaises(xmlrpclib.Fault, self.site.add_comment, self.comments[0])
Exemplo n.º 4
0
  def test_add_comment_ignores_500_duplicate_fault(self):
    self.mox.StubOutWithMock(wordpress, 'get_post_id')
    wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

    fault = xmlrpclib.Fault(500, 'Duplicate comment detected!')
    self.expect_xmlrpc('wp.newComment', 999, '', '', 789,
                       author='me', author_url='http://me',
                       content=self.expected_content,
                       ).AndRaise(fault)
    self.mox.ReplayAll()

    self.site.add_comment(self.comments[0])
Exemplo n.º 5
0
    def test_add_comment(self):
        self.mox.StubOutWithMock(wordpress, 'get_post_id')
        wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

        self.expect_xmlrpc_ok('wp.newComment',
                              999,
                              '',
                              '',
                              789,
                              author='me',
                              author_url='http://me',
                              content=self.expected_content)
        self.mox.ReplayAll()
        self.site.add_comment(self.comments[0])
Exemplo n.º 6
0
    def test_add_comment_reformat(self):
        """<br /> in comments should be converted to <p />."""
        self.mox.StubOutWithMock(wordpress, 'get_post_id')
        wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

        self.comments[0].content = 'bar<br />foo'
        expected = 'bar<p />' + self.expected_content
        self.expect_xmlrpc_ok('wp.newComment',
                              999,
                              '',
                              '',
                              789,
                              author='me',
                              author_url='http://me',
                              content=expected)
        self.mox.ReplayAll()
        self.site.add_comment(self.comments[0])
Exemplo n.º 7
0
    def test_add_comment_ignores_500_duplicate_fault(self):
        self.mox.StubOutWithMock(wordpress, 'get_post_id')
        wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

        fault = xmlrpclib.Fault(500, 'Duplicate comment detected!')
        self.expect_xmlrpc(
            'wp.newComment',
            999,
            '',
            '',
            789,
            author='me',
            author_url='http://me',
            content=self.expected_content,
        ).AndRaise(fault)
        self.mox.ReplayAll()

        self.site.add_comment(self.comments[0])
Exemplo n.º 8
0
    def test_add_comment_passes_through_other_fault(self):
        self.mox.StubOutWithMock(wordpress, 'get_post_id')
        wordpress.get_post_id('http://dest1/post/url').AndReturn(789)

        fault = xmlrpclib.Fault(500, 'other error')
        self.expect_xmlrpc(
            'wp.newComment',
            999,
            '',
            '',
            789,
            author='me',
            author_url='http://me',
            content=self.expected_content,
        ).AndRaise(fault)
        self.mox.ReplayAll()

        self.assertRaises(xmlrpclib.Fault, self.site.add_comment,
                          self.comments[0])