~opencrea/+junk/aprobio

« back to all changes in this revision

Viewing changes to mail_attach_existing_attachment/tests/test_mail_attach_existing_attachment.py

  • Committer: joannes
  • Date: 2017-05-17 09:40:42 UTC
  • Revision ID: joannes@debian-20170517094042-47q3j6on72w2h1il
community module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#     This file is part of mail_attach_existing_attachment,
 
5
#     an Odoo module.
 
6
#
 
7
#     Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
 
8
#
 
9
#     mail_attach_existing_attachment is free software:
 
10
#     you can redistribute it and/or modify it under the terms of the GNU
 
11
#     Affero General Public License as published by the Free Software
 
12
#     Foundation,either version 3 of the License, or (at your option) any
 
13
#     later version.
 
14
#
 
15
#     mail_attach_existing_attachment is distributed
 
16
#     in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 
17
#     even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
18
#     PURPOSE.  See the GNU Affero General Public License for more details.
 
19
#
 
20
#     You should have received a copy of the GNU Affero General Public License
 
21
#     along with mail_attach_existing_attachment.
 
22
#     If not, see <http://www.gnu.org/licenses/>.
 
23
#
 
24
##############################################################################
 
25
 
 
26
from openerp.tests import common
 
27
 
 
28
 
 
29
class TestAttachExistingAttachment(common.TransactionCase):
 
30
 
 
31
    def setUp(self):
 
32
        super(TestAttachExistingAttachment, self).setUp()
 
33
        self.partner_obj = self.env['res.partner']
 
34
        self.partner_01 = self.env.ref('base.res_partner_1')
 
35
 
 
36
    def test_send_email_attachment(self):
 
37
        attach1 = self.env['ir.attachment'].create({
 
38
            'name': 'Attach1', 'datas_fname': 'Attach1',
 
39
            'datas': 'bWlncmF0aW9uIHRlc3Q=',
 
40
            'res_model': 'res.partner', 'res_id': self.partner_01.id})
 
41
        vals = {'model': 'res.partner',
 
42
                'partner_ids': [(6, 0, [self.partner_01.id])],
 
43
                'res_id': self.partner_01.id,
 
44
                'object_attachment_ids': [(6, 0, [attach1.id])]
 
45
                }
 
46
        mail = self.env['mail.compose.message'].create(vals)
 
47
        values = mail.get_mail_values([self.partner_01.id])
 
48
        self.assertTrue(attach1.id in
 
49
                        values[self.partner_01.id]['attachment_ids'])