Skip to content

Commit

Permalink
[FIX] product_contract: Fix mock usage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed May 26, 2017
1 parent b694c9c commit 8de0383
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions product_contract/tests/test_sale_order.py
Expand Up @@ -2,7 +2,7 @@
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from mock import MagicMock
import mock
from odoo.tests.common import TransactionCase


Expand All @@ -23,12 +23,11 @@ def setUp(self):
def test_action_done(self):
""" It should create a contract when the sale for a contract is set
to done for the first time """
self.env['account.analytic.account']._patch_method(
'create', MagicMock()
)
self.sale.action_confirm()
self.env['account.analytic.account'].create.assert_called_once_with({
'name': '%s Contract' % self.sale.name,
'partner_id': self.sale.partner_id.id,
'contract_template_id': self.contract.id,
})
Model = self.env['account.analytic.account']
with mock.patch.object(Model, 'create'):
self.sale.action_confirm()
Model.create.assert_called_once_with({
'name': '%s Contract' % self.sale.name,
'partner_id': self.sale.partner_id.id,
'contract_template_id': self.contract.id,
})

0 comments on commit 8de0383

Please sign in to comment.