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 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 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