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 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
def setUp(self): super(TestComments, self).setUp() post = WordPressPost() post.title = 'Comments Test Post' post.slug = 'comments-test-post' post.user = self.userid post.comment_status = 'open' self.post_id = self.client.call(posts.NewPost(post))
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