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 c442ac2
Show file tree
Hide file tree
Showing 3 changed files with 51 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
15 changes: 15 additions & 0 deletions connector_carepoint/tests/test_carepoint_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ def test_cron_import_sale_order_import(self):
self.backend.cron_import_sale_order()
mk().import_sale_order.assert_called_once_with()

def test_cron_import_phone_import(self):
""" It should call import on found backends """
with mock.patch.object(self.backend, 'search') as mk:
self.backend.cron_import_phone()
mk().import_phone.assert_called_once_with()

def test_import_carepoint_item(self):
""" It should import proper model on date field """
with mock.patch.object(self.backend, '_import_from_date') as mk:
Expand Down Expand Up @@ -249,6 +255,15 @@ def test_import_account_invoice(self):
'primary_pay_date',
)

def test_import_phone(self):
""" It should import proper model on date field """
with mock.patch.object(self.backend, '_import_from_date') as mk:
self.backend.import_phone()
mk.assert_called_once_with(
'carepoint.carepoint.phone',
'import_phones_from_date',
)

def test_import_fdb(self):
""" It should import all of the required FDB models """
with mock.patch.object(self.backend, '_import_all') as mk:
Expand Down

0 comments on commit c442ac2

Please sign in to comment.