Esempio n. 1
0
    def test_unpublish_blog_post(self):
        blog_services.update_blog_post(
            self.blog_post_a_id, self.change_dict_two)
        blog_services.publish_blog_post(self.blog_post_a_id)
        blog_post_rights = (
            blog_services.get_blog_post_rights(self.blog_post_a_id))
        self.assertTrue(blog_post_rights.blog_post_is_published)

        blog_services.unpublish_blog_post(self.blog_post_a_id)
        blog_post_rights = (
            blog_services.get_blog_post_rights(self.blog_post_a_id))
        self.assertFalse(blog_post_rights.blog_post_is_published)
Esempio n. 2
0
    def test_get_authors_page_data(self):
        self.login(self.user_email)
        json_response = self.get_json(
            '%s/%s' % (feconf.AUTHOR_SPECIFIC_BLOG_POST_PAGE_URL_PREFIX,
                       self.BLOG_ADMIN_USERNAME), )
        self.assertEqual(self.BLOG_ADMIN_USERNAME,
                         json_response['summary_dicts'][0]['author_name'])
        self.assertEqual(len(json_response['summary_dicts']), 1)
        self.assertIsNotNone(json_response['profile_picture_data_url'])

        blog_services.unpublish_blog_post(self.blog_post.id)
        json_response = self.get_json(
            '%s/%s' % (feconf.AUTHOR_SPECIFIC_BLOG_POST_PAGE_URL_PREFIX,
                       self.BLOG_ADMIN_USERNAME), )
        self.assertEqual(json_response['summary_dicts'], [])
Esempio n. 3
0
    def put(self, blog_post_id: str) -> None:
        """Updates properties of the given blog post."""
        blog_domain.BlogPost.require_valid_blog_post_id(blog_post_id)
        blog_post_rights = (blog_services.get_blog_post_rights(blog_post_id,
                                                               strict=False))
        blog_post_currently_published = blog_post_rights.blog_post_is_published
        change_dict = self.normalized_payload.get('change_dict')

        blog_services.update_blog_post(blog_post_id, change_dict)
        new_publish_status = self.normalized_payload.get('new_publish_status')
        if new_publish_status:
            blog_services.publish_blog_post(blog_post_id)
        elif blog_post_currently_published:
            blog_services.unpublish_blog_post(blog_post_id)

        blog_post_dict = (
            blog_services.get_blog_post_by_id(blog_post_id).to_dict())

        self.values.update({'blog_post': blog_post_dict})
        self.render_json(self.values)
Esempio n. 4
0
 def test_cannot_unpublish_invalid_blog_post(self):
     blog_services.delete_blog_post(self.blog_post_a_id)
     with self.assertRaisesRegex(
         Exception, ('The given blog post does not exist')):
         blog_services.unpublish_blog_post(self.blog_post_a_id)
Esempio n. 5
0
 def test_cannot_unpublish_invalid_blog_post(self) -> None:
     blog_services.delete_blog_post(self.blog_post_a_id)
     with self.assertRaisesRegex(  # type: ignore[no-untyped-call]
         Exception, ('The given blog post does not exist')):
         blog_services.unpublish_blog_post(self.blog_post_a_id)