social/mass_mailing_partner/tests/test_res_partner.py

40 lines
1.6 KiB
Python
Raw Normal View History

2015-08-28 11:15:50 +02:00
# -*- coding: utf-8 -*-
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2015-08-28 11:15:50 +02:00
from . import base
from odoo.exceptions import ValidationError
2015-08-28 11:15:50 +02:00
class ResPartnerCase(base.BaseCase):
def test_count_mass_mailing_contacts(self):
self.create_mailing_contact({'email': 'partner@test.com',
'list_id': self.mailing_list.id})
self.create_mailing_contact({'email': 'partner@test.com',
'list_id': self.mailing_list2.id})
self.assertEqual(self.partner.mass_mailing_contacts_count, 2)
def test_write_res_partner(self):
user = self.env['res.users'].create({
'login': 'test',
'name': 'test',
'email': 'test@example.org',
'groups_id': [
(4, self.env.ref('base.group_user').id),
(4, self.env.ref('base.group_partner_manager').id),
]
})
2015-08-28 11:15:50 +02:00
contact = self.create_mailing_contact(
{'email': 'partner@test.com', 'list_id': self.mailing_list.id})
self.partner.sudo(user).write({
'name': 'Changed',
'email': 'partner@changed.com',
})
2015-08-28 11:15:50 +02:00
self.assertEqual(contact.name, self.partner.name)
self.assertEqual(contact.email, self.partner.email)
with self.assertRaises(ValidationError):
self.partner.write({'email': False})