Skip to content

Commit

Permalink
[9.0][FIX] mail_auto_follower_notify: inheritance issue + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Sep 5, 2017
1 parent 00351c2 commit 6f81873
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mail_auto_follower_notify/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Odoo Community Association (OCA)",
"website": "https://odoo-community.org/",
"category": "Mail",
"depends": ["mail"],
"depends": ["mail", "base_patch_models_mixin"],
"license": "AGPL-3",
'installable': True,
'application': False,
Expand Down
3 changes: 2 additions & 1 deletion mail_auto_follower_notify/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


class MailThread(models.AbstractModel):
_inherit = 'mail.thread'
_name = 'mail.thread'
_inherit = ['base.patch.models.mixin', 'mail.thread']

@api.multi
def _message_auto_subscribe_notify(self, partner_ids):
Expand Down
24 changes: 16 additions & 8 deletions mail_auto_follower_notify/tests/test_auto_follower_notify.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright <YEAR(S)> <AUTHOR(S)>
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp.tests.common import TransactionCase
from openerp.tests.common import TransactionCase, at_install, post_install


class TestAutoFollowerNotify(TransactionCase):
Expand All @@ -12,17 +13,24 @@ def setUp(self):
'name': 'Test Record',
})
self.user = self.env['res.users'].create({
'name': 'Test user',
'login': 'test_login',
})
'name': 'Test user',
'login': 'test_login',
'password': 'demo',
'email': 'test@yourcompany.com',
})

@at_install(False)
@post_install(True)
def test_something(self):
"""Test module functionality."""
items = self.test_record._fields.items()
user_id = filter(lambda (n, f): n == 'user_id', items)
"""Test module functionality. The test must be run after the
installation to ensure that the patch done in
``base_patch_models_mixin`` is applied."""
# Set manually a res.users field to track visibility in order to be
# able to test the module without extra dependencies.
items = self.test_record._fields.items()
user_id = filter(lambda (n, f): n == 'user_id', items)
setattr(user_id[0][1], 'track_visibility', 'always')
# Update the field with a user:
self.test_record.user_id = self.user.id
self.assertTrue(
self.test_record.message_follower_ids, "Follower not notified.")

0 comments on commit 6f81873

Please sign in to comment.