Skip to content

Commit

Permalink
[FIX] connector_carepoint: Fix account sequencing
Browse files Browse the repository at this point in the history
* PK for cp_acct is `ID`, but sequence is `acct_id`. Overload create and inject
  • Loading branch information
lasley committed Oct 28, 2016
1 parent 34bd1e4 commit 87e9e21
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions connector_carepoint/models/carepoint_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ def _get_by_patient(self, patient, create=True, recurse=False):
class CarepointAccountAdapter(CarepointCRUDAdapter):
_model_name = 'carepoint.carepoint.account'

def create(self, data):
""" Wrapper to create a record on the external system
Params:
data: ``dict`` of Data to create record with
Returns:
``str`` of external carepoint_id
"""
data['ID'] = self.carepoint.get_next_sequence('acct_id')
return super(CarepointAccountAdapter, self).create(data)


@carepoint
class CarepointAccountUnit(ConnectorUnit):
Expand Down
17 changes: 17 additions & 0 deletions connector_carepoint/tests/models/test_carepoint_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ def test_get_by_patient_recurse(self):
self.assertTrue(len(account))


class TestAccountAdapter(AccountTestBase):

def setUp(self):
super(TestAccountAdapter, self).setUp()
self.Unit = carepoint_account.CarepointAccountAdapter
self.unit = self.Unit(self.mock_env)
self.unit.carepoint_record = self.record

def create_gets_sequence(self):
""" It should get the sequence for acct_id instead of PK """
with self.mock_api(True) as api:
self.unit.create({})
api.get_next_sequence.assert_called_once_with(
'acct_id',
)


class TestAccountImportMapper(AccountTestBase):

def setUp(self):
Expand Down

0 comments on commit 87e9e21

Please sign in to comment.