Skip to content

Commit

Permalink
MHR search report exemption message update. (#1256)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <doug@diamante.ca>
  • Loading branch information
doug-lovett authored Mar 30, 2023
1 parent 558a1ff commit 8345886
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
13 changes: 12 additions & 1 deletion mhr_api/src/mhr_api/models/db2/manuhome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion mhr_api/src/mhr_api/reports/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mhr_api/src/mhr_api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.3.0' # pylint: disable=invalid-name
__version__ = '1.3.1' # pylint: disable=invalid-name
6 changes: 5 additions & 1 deletion mhr_api/tests/unit/models/db2/test_manuhome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions mhr_api/tests/unit/models/test_mhr_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 8345886

Please sign in to comment.