Server IP : 127.0.0.2 / Your IP : 3.15.145.122 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/website_blog/tests/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.website_blog.tests.common import TestWebsiteBlogCommon class TestWebsiteBlogFlow(TestWebsiteBlogCommon): def test_website_blog_followers(self): """ Test the flow of followers and notifications for blogs. Intended flow : - people subscribe to a blog - when creating a new post, nobody except the creator follows it - people subscribed to the blog does not receive comments on posts - when published, a notification is sent to all blog followers - if someone subscribe to the post or comment it, it become follower and receive notification for future comments. """ # Create a new blog, subscribe the employee to the blog test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({ 'name': 'New Blog', }) self.assertIn( self.user_blogmanager.partner_id, test_blog.message_partner_ids, 'website_blog: blog create should be in the blog followers') test_blog.message_subscribe([self.user_employee.partner_id.id, self.user_public.partner_id.id]) # Create a new post, blog followers should not follow the post test_blog_post = self.env['blog.post'].sudo(self.user_blogmanager).create({ 'name': 'New Post', 'blog_id': test_blog.id, }) self.assertNotIn( self.user_employee.partner_id, test_blog_post.message_partner_ids, 'website_blog: subscribing to a blog should not subscribe to its posts') self.assertNotIn( self.user_public.partner_id, test_blog_post.message_partner_ids, 'website_blog: subscribing to a blog should not subscribe to its posts') # Publish the blog test_blog_post.write({'website_published': True}) # Check publish message has been sent to blog followers publish_message = next((m for m in test_blog_post.blog_id.message_ids if m.subtype_id.id == self.ref('website_blog.mt_blog_blog_published')), None) self.assertEqual( publish_message.needaction_partner_ids, self.user_employee.partner_id | self.user_public.partner_id, 'website_blog: peuple following a blog should be notified of a published post') # Armand posts a message -> becomes follower test_blog_post.sudo().message_post( body='Armande BlogUser Commented', message_type='comment', author_id=self.user_employee.partner_id.id, subtype='mt_comment', ) self.assertIn( self.user_employee.partner_id, test_blog_post.message_partner_ids, 'website_blog: people commenting a post should follow it afterwards')