Skip to content

Commit

Permalink
[ADD] connector_carepoint: Increase Test coverage
Browse files Browse the repository at this point in the history
* Cleanup existing model code, remove now-centralized & unused logic
* Add tests for models:
  * medical_pharmacy
  * procurement_order
  * fdb_unit
  * fdb_pem_mogc
  * account_invoice_line
  * medical_prescription_order_line
  * sale_order_line
  * sale_order
  * stock_picking
  • Loading branch information
lasley committed Aug 18, 2016
1 parent cadff65 commit c97e0af
Show file tree
Hide file tree
Showing 47 changed files with 2,374 additions and 1,492 deletions.
8 changes: 0 additions & 8 deletions connector_carepoint/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ class AccountBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.carepoint.account']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class AccountImportMapper(CarepointImportMapper):
Expand Down
46 changes: 0 additions & 46 deletions connector_carepoint/models/account_invoice_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from openerp import models, fields
from openerp.addons.connector.connector import ConnectorUnit
from openerp.addons.connector.unit.mapper import (mapping,
changed_by,
only_create,
ExportMapper,
)
Expand All @@ -18,7 +17,6 @@
)
from ..unit.export_synchronizer import (CarepointExporter)
from ..unit.delete_synchronizer import (CarepointDeleter)
from ..connector import add_checkpoint
from .procurement_order import ProcurementOrderUnit


Expand Down Expand Up @@ -95,14 +93,6 @@ class AccountInvoiceLineBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.account.invoice.line']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class AccountInvoiceLineImportMapper(CarepointImportMapper):
Expand Down Expand Up @@ -158,12 +148,6 @@ class AccountInvoiceLineImporter(CarepointImporter):

_base_mapper = AccountInvoiceLineImportMapper

def _create(self, data):
binding = super(AccountInvoiceLineImporter, self)._create(data)
checkpoint = self.unit_for(AccountInvoiceLineAddCheckpoint)
checkpoint.run(binding.id)
return binding

def _import_dependencies(self):
""" Import depends for record """
record = self.carepoint_record
Expand Down Expand Up @@ -206,22 +190,6 @@ def _after_import(self, binding):
class AccountInvoiceLineExportMapper(ExportMapper):
_model_name = 'carepoint.account.invoice.line'

direct = [
('ref', 'ssn'),
('email', 'email'),
('dob', 'birth_date'),
('dod', 'death_date'),
]

@mapping
def pat_id(self, record):
return {'pat_id': record.carepoint_id}

@changed_by('gender')
@mapping
def gender_cd(self, record):
return {'gender_cd': record.get('gender').upper()}


@carepoint
class AccountInvoiceLineExporter(CarepointExporter):
Expand All @@ -232,17 +200,3 @@ class AccountInvoiceLineExporter(CarepointExporter):
@carepoint
class AccountInvoiceLineDeleteSynchronizer(CarepointDeleter):
_model_name = ['carepoint.account.invoice.line']


@carepoint
class AccountInvoiceLineAddCheckpoint(ConnectorUnit):
""" Add a connector.checkpoint on the carepoint.account.invoice.line
record
"""
_model_name = ['carepoint.account.invoice.line', ]

def run(self, binding_id):
add_checkpoint(self.session,
self.model._name,
binding_id,
self.backend_record.id)
41 changes: 0 additions & 41 deletions connector_carepoint/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
from openerp import models, fields
from openerp.addons.connector.queue.job import job
from openerp.addons.connector.connector import ConnectorUnit
from openerp.addons.connector.unit.mapper import (mapping,
ExportMapper
Expand All @@ -18,7 +17,6 @@
)
from ..unit.export_synchronizer import (CarepointExporter)
from ..unit.delete_synchronizer import (CarepointDeleter)
from ..connector import add_checkpoint, get_environment


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -113,14 +111,6 @@ class CarepointAddressBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.carepoint.address']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class CarepointAddressImportMapper(CarepointImportMapper):
Expand Down Expand Up @@ -160,15 +150,8 @@ def carepoint_id(self, record):
@carepoint
class CarepointAddressImporter(CarepointImporter):
_model_name = ['carepoint.carepoint.address']

_base_mapper = CarepointAddressImportMapper

def _create(self, data):
binding = super(CarepointAddressImporter, self)._create(data)
checkpoint = self.unit_for(CarepointAddressAddCheckpoint)
checkpoint.run(binding.id)
return binding

#
# def _after_import(self, partner_binding):
# """ Import the addresses """
Expand Down Expand Up @@ -200,27 +183,3 @@ class CarepointAddressExporter(CarepointExporter):
@carepoint
class CarepointAddressDeleteSynchronizer(CarepointDeleter):
_model_name = ['carepoint.carepoint.address']


@carepoint
class CarepointAddressAddCheckpoint(ConnectorUnit):
""" Add a connector.checkpoint on the carepoint.address record """
_model_name = ['carepoint.carepoint.address', ]

def run(self, binding_id):
add_checkpoint(self.session,
self.model._name,
binding_id,
self.backend_record.id)


@job(default_channel='root.carepoint.core')
def carepoint_address_import_batch(session, model_name, backend_id,
filters=None
):
""" Prepare the import of addresss modified on Carepoint """
if filters is None:
filters = {}
env = get_environment(session, model_name, backend_id)
importer = env.get_connector_unit(CarepointAddressBatchImporter)
importer.run(filters=filters)
41 changes: 0 additions & 41 deletions connector_carepoint/models/address_patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
from openerp import models, fields
from openerp.addons.connector.queue.job import job
from openerp.addons.connector.connector import ConnectorUnit
from openerp.addons.connector.unit.mapper import (mapping,
only_create,
Expand All @@ -15,7 +14,6 @@
from ..unit.import_synchronizer import (DelayedBatchImporter,
CarepointImporter,
)
from ..connector import add_checkpoint, get_environment


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,14 +84,6 @@ class CarepointAddressPatientBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.carepoint.address.patient']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class CarepointAddressPatientImportMapper(CarepointImportMapper):
Expand Down Expand Up @@ -137,15 +127,8 @@ def carepoint_id(self, record):
@carepoint
class CarepointAddressPatientImporter(CarepointImporter):
_model_name = ['carepoint.carepoint.address.patient']

_base_mapper = CarepointAddressPatientImportMapper

def _create(self, data):
binding = super(CarepointAddressPatientImporter, self)._create(data)
checkpoint = self.unit_for(CarepointAddressPatientAddCheckpoint)
checkpoint.run(binding.id)
return binding

def _import_dependencies(self):
""" Import depends for record """
record = self.carepoint_record
Expand All @@ -165,27 +148,3 @@ def _import_addresses(self, patient_id, binding_id):
address_ids = adapter.search(pat_id=patient_id)
for address_id in address_ids:
importer.run(address_id)


@carepoint
class CarepointAddressPatientAddCheckpoint(ConnectorUnit):
""" Add a connector.checkpoint on the carepoint.address.patient record """
_model_name = ['carepoint.carepoint.address.patient', ]

def run(self, binding_id):
add_checkpoint(self.session,
self.model._name,
binding_id,
self.backend_record.id)


@job(default_channel='root.carepoint.patient')
def carepoint_address_patient_import_batch(session, model_name, backend_id,
filters=None
):
""" Prepare the import of addresss modified on Carepoint """
if filters is None:
filters = {}
env = get_environment(session, model_name, backend_id)
importer = env.get_connector_unit(CarepointAddressPatientBatchImporter)
importer.run(filters=filters)
43 changes: 0 additions & 43 deletions connector_carepoint/models/address_pharmacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import logging
from openerp import models, fields
from openerp.addons.connector.queue.job import job
from openerp.addons.connector.connector import ConnectorUnit
from openerp.addons.connector.unit.mapper import (mapping,
only_create,
)
Expand All @@ -15,7 +13,6 @@
from ..unit.import_synchronizer import (DelayedBatchImporter,
CarepointImporter,
)
from ..connector import add_checkpoint, get_environment


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,14 +83,6 @@ class CarepointAddressPharmacyBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.carepoint.address.pharmacy']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class CarepointAddressPharmacyImportMapper(CarepointImportMapper):
Expand Down Expand Up @@ -138,42 +127,10 @@ def carepoint_id(self, record):
@carepoint
class CarepointAddressPharmacyImporter(CarepointImporter):
_model_name = ['carepoint.carepoint.address.pharmacy']

_base_mapper = CarepointAddressPharmacyImportMapper

def _create(self, data):
binding = super(CarepointAddressPharmacyImporter, self)._create(data)
checkpoint = self.unit_for(CarepointAddressPharmacyAddCheckpoint)
checkpoint.run(binding.id)
return binding

def _import_dependencies(self):
""" Import depends for record """
record = self.carepoint_record
self._import_dependency(record['addr_id'],
'carepoint.carepoint.address')


@carepoint
class CarepointAddressPharmacyAddCheckpoint(ConnectorUnit):
""" Add a connector.checkpoint on the carepoint.address.pharmacy record
"""
_model_name = ['carepoint.carepoint.address.pharmacy', ]

def run(self, binding_id):
add_checkpoint(self.session,
self.model._name,
binding_id,
self.backend_record.id)


@job(default_channel='root.carepoint.core')
def carepoint_address_pharmacy_import_batch(session, model_name, backend_id,
filters=None
):
""" Prepare the import of addresss modified on Carepoint """
if filters is None:
filters = {}
env = get_environment(session, model_name, backend_id)
importer = env.get_connector_unit(CarepointAddressPharmacyBatchImporter)
importer.run(filters=filters)
43 changes: 0 additions & 43 deletions connector_carepoint/models/address_physician.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import logging
from openerp import models, fields
from openerp.addons.connector.queue.job import job
from openerp.addons.connector.connector import ConnectorUnit
from openerp.addons.connector.unit.mapper import (mapping,
only_create,
)
Expand All @@ -15,7 +13,6 @@
from ..unit.import_synchronizer import (DelayedBatchImporter,
CarepointImporter,
)
from ..connector import add_checkpoint, get_environment


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,14 +83,6 @@ class CarepointAddressPhysicianBatchImporter(DelayedBatchImporter):
"""
_model_name = ['carepoint.carepoint.address.physician']

def run(self, filters=None):
""" Run the synchronization """
if filters is None:
filters = {}
record_ids = self.backend_adapter.search(**filters)
for record_id in record_ids:
self._import_record(record_id)


@carepoint
class CarepointAddressPhysicianImportMapper(CarepointImportMapper):
Expand Down Expand Up @@ -138,42 +127,10 @@ def carepoint_id(self, record):
@carepoint
class CarepointAddressPhysicianImporter(CarepointImporter):
_model_name = ['carepoint.carepoint.address.physician']

_base_mapper = CarepointAddressPhysicianImportMapper

def _create(self, data):
binding = super(CarepointAddressPhysicianImporter, self)._create(data)
checkpoint = self.unit_for(CarepointAddressPhysicianAddCheckpoint)
checkpoint.run(binding.id)
return binding

def _import_dependencies(self):
""" Import depends for record """
record = self.carepoint_record
self._import_dependency(record['addr_id'],
'carepoint.carepoint.address')


@carepoint
class CarepointAddressPhysicianAddCheckpoint(ConnectorUnit):
""" Add a connector.checkpoint on the carepoint.address.physician record
"""
_model_name = ['carepoint.carepoint.address.physician', ]

def run(self, binding_id):
add_checkpoint(self.session,
self.model._name,
binding_id,
self.backend_record.id)


@job(default_channel='root.carepoint.physician')
def carepoint_address_physician_import_batch(session, model_name, backend_id,
filters=None
):
""" Prepare the import of addresss modified on Carepoint """
if filters is None:
filters = {}
env = get_environment(session, model_name, backend_id)
importer = env.get_connector_unit(CarepointAddressPhysicianBatchImporter)
importer.run(filters=filters)
Loading

0 comments on commit c97e0af

Please sign in to comment.