diff --git a/mhr_api/src/mhr_api/models/db2/manuhome.py b/mhr_api/src/mhr_api/models/db2/manuhome.py index 56074684d..9ea41b557 100755 --- a/mhr_api/src/mhr_api/models/db2/manuhome.py +++ b/mhr_api/src/mhr_api/models/db2/manuhome.py @@ -428,7 +428,9 @@ def registration_json(self): if self.reg_notes: notes = [] for note in self.reg_notes: - notes.append(note.registration_json) + note_json = note.registration_json + note_json['documentRegistrationNumber'] = self.__get_note_doc_reg_num(note.reg_document_id) + notes.append(note_json) # Now sort in descending timestamp order. man_home['notes'] = Db2Manuhome.__sort_notes(notes) return man_home @@ -486,6 +488,15 @@ def new_registration_json(self): man_home['description'] = self.reg_descript.registration_json return man_home + def __get_note_doc_reg_num(self, doc_id: str) -> str: + """Get the document registration number matching the doc_id from document.""" + reg_num: str = '' + if doc_id and self.reg_documents: + for doc in self.reg_documents: + if doc.id == doc_id: + return doc.document_reg_id + return reg_num + @classmethod def __update_group_type(cls, groups, existing_count: int = 0): """Set type if multiple active owner groups and a trustee, admin, executor exists.""" diff --git a/mhr_api/src/mhr_api/reports/v2/report.py b/mhr_api/src/mhr_api/reports/v2/report.py index 9821f7eba..0e467f57d 100755 --- a/mhr_api/src/mhr_api/reports/v2/report.py +++ b/mhr_api/src/mhr_api/reports/v2/report.py @@ -460,7 +460,7 @@ def _set_search_additional_message(self): has_exempt_note = True message = { 'messageType': note.get('documentType'), - 'messageId': note.get('documentId', ''), + 'messageId': note.get('documentRegistrationNumber', ''), 'messageDate': Report._to_report_datetime(note['createDateTime'], False) } messages.append(message) diff --git a/mhr_api/src/mhr_api/version.py b/mhr_api/src/mhr_api/version.py index 58a71787b..c9f571685 100644 --- a/mhr_api/src/mhr_api/version.py +++ b/mhr_api/src/mhr_api/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.3.0' # pylint: disable=invalid-name +__version__ = '1.3.1' # pylint: disable=invalid-name diff --git a/mhr_api/tests/unit/models/db2/test_manuhome.py b/mhr_api/tests/unit/models/db2/test_manuhome.py index 1ee62b57f..ba559c371 100755 --- a/mhr_api/tests/unit/models/db2/test_manuhome.py +++ b/mhr_api/tests/unit/models/db2/test_manuhome.py @@ -186,6 +186,8 @@ def test_find_by_mhr_number(session, http_status, id, mhr_num, status, doc_id): assert report_json.get('location') assert report_json.get('description') assert report_json.get('notes') + for note in report_json.get('notes'): + assert note.get('documentRegistrationNumber') else: with pytest.raises(BusinessException) as request_err: Db2Manuhome.find_by_mhr_number(mhr_num) @@ -267,6 +269,7 @@ def test_find_by_document_id(session, http_status, doc_id, mhr_num, doc_type): @pytest.mark.parametrize('interest,numerator,denominator,new_interest', TEST_DATA_GROUP_INTEREST) def test_adjust_group_interest_new(session, interest, numerator, denominator, new_interest): + """Assert that adjusting group interest is working as expected.""" groups = [] group: Db2Owngroup = Db2Owngroup(status=Db2Owngroup.StatusTypes.ACTIVE, tenancy_type=Db2Owngroup.TenancyTypes.COMMON, @@ -280,6 +283,7 @@ def test_adjust_group_interest_new(session, interest, numerator, denominator, ne @pytest.mark.parametrize('group1,group2,group3,interest1,interest2,interest3', TEST_DATA_GROUP_INTEREST2) def test_adjust_group_interest_2(session, group1, group2, group3, interest1, interest2, interest3): + """Assert that adjusting group interest is working as expected.""" groups = [] if group1: groups.append(group1) @@ -298,7 +302,7 @@ def test_adjust_group_interest_2(session, group1, group2, group3, interest1, int def test_notes_sort_order(session): - """Assert that manufauctured home notes sort order is as expected.""" + """Assert that manufactured home notes sort order is as expected.""" manuhome: Db2Manuhome = Db2Manuhome.find_by_mhr_number('053341') report_json = manuhome.registration_json assert len(report_json['notes']) == 2 diff --git a/mhr_api/tests/unit/models/test_mhr_registration.py b/mhr_api/tests/unit/models/test_mhr_registration.py index 638a3a1c9..051a9295e 100755 --- a/mhr_api/tests/unit/models/test_mhr_registration.py +++ b/mhr_api/tests/unit/models/test_mhr_registration.py @@ -560,6 +560,19 @@ def test_find_by_mhr_number(session, mhr_number, has_results, account_id): assert registration.status_type in MhrRegistrationStatusTypes assert registration.registration_type in MhrRegistrationTypes assert registration.registration_ts + report_json = registration.registration_json + assert report_json['mhrNumber'] + assert report_json['status'] + assert report_json.get('createDateTime') + assert report_json.get('clientReferenceId') is not None + assert report_json.get('declaredValue') >= 0 + assert report_json.get('ownerGroups') + assert report_json.get('location') + assert report_json.get('description') + if report_json.get('notes'): + for note in report_json.get('notes'): + assert note['documentDescription'] + assert note['documentRegistrationNumber'] else: with pytest.raises(BusinessException) as not_found_err: MhrRegistration.find_by_mhr_number(mhr_number, 'PS12345')