Browse Source

[ADD] Unittest.

pull/649/head
David 6 years ago
parent
commit
e9c584cdd3
  1. 1
      partner_children_navigation/__init__.py
  2. 2
      partner_children_navigation/models/res_partner.py
  3. 1
      partner_children_navigation/tests/__init__.py
  4. 33
      partner_children_navigation/tests/test_res_partner.py

1
partner_children_navigation/__init__.py

@ -1 +1,2 @@
from . import models from . import models
from . import tests

2
partner_children_navigation/models/res_partner.py

@ -7,8 +7,6 @@ from odoo import api, fields, models
class Partner(models.Model): class Partner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
contact_origin = fields.Many2one('res.partner', string='Contact origin')
@api.multi @api.multi
def open_commercial_partner(self): def open_commercial_partner(self):
""" """

1
partner_children_navigation/tests/__init__.py

@ -0,0 +1 @@
from . import test_res_partner

33
partner_children_navigation/tests/test_res_partner.py

@ -0,0 +1,33 @@
# SDi
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
class TestResPartnerNav(TransactionCase):
def setUp(self):
super(TestResPartnerNav, self).setUp()
res_partner = self.env['res.partner']
self.parent = res_partner.browse(
res_partner.name_create('IronShield')[0])
self.child = res_partner.create({
'name': 'Isen Hardearth',
'street': 'Strongarm Avenue, 12',
'parent_id': self.parent.id,
})
def test_open_commercial_partner(self):
""" This test case checks
- If the method redirects to the form view of the correct one
of an object of the 'res.partner' class.
"""
for child in self.parent.child_ids:
action = child.open_commercial_partner()
print("Child_id = {}".format(child.id))
print("action.get('res_id') = {}".format(action.get('res_id')))
self.assertEqual(child.id, action.get('res_id'),
'The contact ID from the partner must be equal to'
' the ID of the contact to be displayed.')
Loading…
Cancel
Save