Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed Oct 27, 2016
1 parent e95b626 commit e69ddef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions connector_carepoint/tests/models/test_address_patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def setUp(self):
super(TestAddressPatientImportMapper, self).setUp()
self.Unit = address_patient.CarepointAddressPatientImportMapper
self.unit = self.Unit(self.mock_env)
self.model = self.env['medical.patient']

def test_partner_id_get_binder(self):
""" It should get binder for patient """
Expand Down Expand Up @@ -70,6 +71,33 @@ def test_carepoint_id(self):
}
self.assertDictEqual(expect, res)

def test_partner_id(self):
""" It should return proper model and ID for patient """
record = self.model.create({
'name': 'Test patient',
})
expect = {
'partner_id': record.commercial_partner_id.id,
}
with mock.patch.object(self.unit, 'binder_for'):
self.unit.binder_for().to_odoo.return_value = record
res = self.unit.partner_id(self.record)
self.assertDictEqual(expect, res)

def test_res_model_and_id(self):
""" It should return proper model and ID for patient """
record = self.model.create({
'name': 'Test patient',
})
expect = {
'res_model': record._name,
'res_id': record.id,
}
with mock.patch.object(self.unit, 'binder_for'):
self.unit.binder_for().to_odoo.return_value = record
res = self.unit.res_model_and_id(self.record)
self.assertDictEqual(expect, res)


class TestAddressPatientImporter(AddressPatientTestBase):

Expand Down Expand Up @@ -166,3 +194,10 @@ def test_pat_id_return(self):
res = self.unit.pat_id(self.record)
expect = self.unit.binder_for().to_backend()
self.assertDictEqual({'pat_id': expect}, res)

def test_static_defaults(self):
""" It should return a dict of default values """
self.assertIsInstance(
self.unit.static_defaults(self.record),
dict,
)
1 change: 1 addition & 0 deletions connector_carepoint/tests/models/test_carepoint_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AccountTestBase(SetUpCarepointBase):

def setUp(self):
super(AccountTestBase, self).setUp()
self.model = 'carepoint.account'
self.mock_env = self.get_carepoint_helper(
self.model
)
Expand Down

0 comments on commit e69ddef

Please sign in to comment.