def test_revisions(self):
        original_title = 'Revisions test'
        post = WordPressPost()
        post.title = original_title
        post.slug = 'revisions-test'
        post.content = 'This is a test post using the XML-RPC API.'
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        post.title = 'Revisions test updated'
        post.content += ' This is a second revision.'
        response = self.client.call(posts.EditPost(post_id, post))
        self.assertTrue(response)

        # test wp.getRevisions
        revision_list = self.client.call(posts.GetRevisions(post_id, ['post']))
        self.assert_list_of_classes(revision_list, WordPressPost)

        # workaround for WP bug #22686/22687
        # an auto-draft revision will survive wp.newPost, so pick the 2nd revision
        self.assertEqual(2, len(revision_list))
        real_rev = revision_list[1]
        self.assertTrue(real_rev)
        self.assertNotEquals(post_id, real_rev.id)

        # test wp.restoreRevision
        response2 = self.client.call(posts.RestoreRevision(real_rev.id))
        self.assertTrue(response2)
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertEquals(original_title, post2.title)

        # cleanup
        self.client.call(posts.DeletePost(post_id))
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post_id = self.client.call(posts.NewPost(post, False))

        # create a test category
        cat = WordPressCategory()
        cat.name = 'Test Category'
        cat.cat_id = self.client.call(categories.NewCategory(cat))

        # set category on post
        response = self.client.call(categories.SetPostCategories(post_id, [cat.struct]))
        self.assertTrue(response)

        # fetch categories for the post to verify
        post_cats = self.client.call(categories.GetPostCategories(post_id))
        self.assert_list_of_classes(post_cats, WordPressCategory)
        self.assertEqual(post_cats[0].cat_id, str(cat.cat_id))

        # cleanup
        self.client.call(categories.DeleteCategory(cat.cat_id))
        self.client.call(posts.DeletePost(post_id))
    def setUp(self):
        super(TestComments, self).setUp()

        post = WordPressPost()
        post.title = 'Comments Test Post'
        post.slug = 'comments-test-post'
        post.user = self.userid
        self.post_id = self.client.call(posts.NewPost(post, True))
Beispiel #4
0
    def setUp(self):
        super(TestComments, self).setUp()

        post = WordPressPost()
        post.title = 'Comments Test Post'
        post.slug = 'comments-test-post'
        post.user = self.userid
        self.post_id = self.client.call(posts.NewPost(post))
Beispiel #5
0
 def assemble_post(self, estate, old_post, published=True):
     post = WordPressPost()
     post_id = None
     post.comment_status = 'open'
     description = self.render_post_description(estate)
     if old_post:
         post_id = old_post.id
     
     post.custom_fields = [
                           {'key': '_aioseop_description', 'value': description}, 
                           {'key': '_aioseop_title', 'value': self.render_seo_post_title(estate)},
                           {'key': '_aioseop_keywords', 'value': u','.join(self.render_post_tags(estate))},
                          ]
     post.custom_fields.extend(self.render_custom_fields(estate))
     if post_id:
         for custom_field in post.custom_fields:
             custom_field['id'] = self.get_custom_field_id(old_post.custom_fields, custom_field.get('key'))
         
     post.title = self.render_post_title(estate)
     post_images = self.render_post_images(estate, post_id)
     images = u''.join(post_images)
     post.content = self.render_post_body(estate, description, images)
     post.terms_names = {'post_tag': self.render_post_tags(estate)}
     post.terms = self.render_post_category(estate)
     post.date = estate.history.modificated - datetime.timedelta(hours=4)
     if published:
         post.post_status = 'publish'
     return post
Beispiel #6
0
    def test_post_lifecycle(self):
        # create a post object
        post = WordPressPost()
        post.title = 'Test post'
        post.slug = 'test-post'
        post.content = 'This is test post using the XML-RPC API.'
        post.comment_status = 'open'
        post.user = self.userid

        # create the post as a draft
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        # fetch the newly-created post
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertTrue(isinstance(post2, WordPressPost))
        self.assertEqual(str(post2.id), post_id)

        # update the post
        post2.content += '<br><b>Updated:</b> This post has been updated.'
        post2.post_status = 'publish'
        response = self.client.call(posts.EditPost(post_id, post2))
        self.assertTrue(response)

        # delete the post
        response = self.client.call(posts.DeletePost(post_id))
        self.assertTrue(response)
Beispiel #7
0
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post.id = self.client.call(posts.NewPost(post))

        # create a test category
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'
        cat.id = self.client.call(taxonomies.NewTerm(cat))

        # set category on post
        try:
            post.terms = [cat]
            response = self.client.call(posts.EditPost(post.id, post))
            self.assertTrue(response)

            # fetch categories for the post to verify
            post2 = self.client.call(posts.GetPost(post.id, ['terms']))
            post_cats = post2.terms
            self.assert_list_of_classes(post_cats, WordPressTerm)
            self.assertEqual(post_cats[0].id, cat.id)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.client.call(posts.DeletePost(post.id))
    def test_post_lifecycle(self):
        # create a post object
        post = WordPressPost()
        post.title = 'Test post'
        post.slug = 'test-post'
        post.content = 'This is test post using the XML-RPC API.'
        post.comment_status = 'open'
        post.user = self.userid

        # create the post as a draft
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        # fetch the newly-created post
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertTrue(isinstance(post2, WordPressPost))
        self.assertEqual(str(post2.id), post_id)

        # update the post
        post2.content += '<br><b>Updated:</b> This post has been updated.'
        post2.post_status = 'publish'
        response = self.client.call(posts.EditPost(post_id, post2))
        self.assertTrue(response)

        # delete the post
        response = self.client.call(posts.DeletePost(post_id))
        self.assertTrue(response)
    def test_post_lifecycle(self):
        # create a post object
        post = WordPressPost()
        post.title = 'Test post'
        post.slug = 'test-post'
        post.description = 'This is test post using the XML-RPC API.'
        post.allow_comments = True
        post.user = self.userid

        # create the post as a draft
        post_id = self.client.call(posts.NewPost(post, False))
        self.assertTrue(post_id)

        # fetch the newly-created post
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertTrue(isinstance(post2, WordPressPost))
        self.assertEqual(str(post2.id), post_id)

        # publish the post
        response = self.client.call(posts.PublishPost(post_id))
        self.assertEqual(str(response), post_id)

        # update the post
        post2.description += '<br><b>Updated:</b> This post has been updated.'
        response = self.client.call(posts.EditPost(post_id, post2, True))
        self.assertTrue(response)

        # delete the post
        response = self.client.call(posts.DeletePost(post_id))
        self.assertTrue(response)
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post.id = self.client.call(posts.NewPost(post))

        # create a test category
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'
        cat.id = self.client.call(taxonomies.NewTerm(cat))

        # set category on post
        try:
            post.terms = [cat]
            response = self.client.call(posts.EditPost(post.id, post))
            self.assertTrue(response)

            # fetch categories for the post to verify
            post2 = self.client.call(posts.GetPost(post.id, ['terms']))
            post_cats = post2.terms
            self.assert_list_of_classes(post_cats, WordPressTerm)
            self.assertEqual(post_cats[0].id, cat.id)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.client.call(posts.DeletePost(post.id))
Beispiel #11
0
    def test_revisions(self):
        original_title = 'Revisions test'
        post = WordPressPost()
        post.title = original_title
        post.slug = 'revisions-test'
        post.content = 'This is a test post using the XML-RPC API.'
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        post.title = 'Revisions test updated'
        post.content += ' This is a second revision.'
        response = self.client.call(posts.EditPost(post_id, post))
        self.assertTrue(response)

        # test wp.getRevisions
        revision_list = self.client.call(posts.GetRevisions(post_id, ['post']))
        self.assert_list_of_classes(revision_list, WordPressPost)

        # workaround for WP bug #22686/22687
        # an auto-draft revision will survive wp.newPost, so pick the 2nd revision
        self.assertEqual(2, len(revision_list))
        real_rev = revision_list[1]
        self.assertTrue(real_rev)
        self.assertNotEquals(post_id, real_rev.id)

        # test wp.restoreRevision
        response2 = self.client.call(posts.RestoreRevision(real_rev.id))
        self.assertTrue(response2)
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertEquals(original_title, post2.title)

        # cleanup
        self.client.call(posts.DeletePost(post_id))
Beispiel #12
0
    def assemble_post(self, estate, old_post, published=True):
        post = WordPressPost()
        post_id = None
        post.comment_status = 'open'
        description = self.render_post_description(estate)
        if old_post:
            post_id = old_post.id

        post.custom_fields = [
            {
                'key': '_aioseop_description',
                'value': description
            },
            {
                'key': '_aioseop_title',
                'value': self.render_seo_post_title(estate)
            },
            {
                'key': '_aioseop_keywords',
                'value': u','.join(self.render_post_tags(estate))
            },
        ]
        post.custom_fields.extend(self.render_custom_fields(estate))
        if post_id:
            for custom_field in post.custom_fields:
                custom_field['id'] = self.get_custom_field_id(
                    old_post.custom_fields, custom_field.get('key'))

        post.title = self.render_post_title(estate)
        post_images = self.render_post_images(estate, post_id)
        images = u''.join(post_images)
        post.content = self.render_post_body(estate, description, images)
        post.terms_names = {'post_tag': self.render_post_tags(estate)}
        post.terms = self.render_post_category(estate)
        post.date = estate.history.modificated - datetime.timedelta(hours=4)
        if published:
            post.post_status = 'publish'
        return post
Beispiel #13
0
 def test_post_repr(self):
     post = WordPressPost()
     repr(post)