Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Rename and update specific programme field in payload to send a list …
Browse files Browse the repository at this point in the history
…of IDs

This is due to recent changes to the field in Data Hub API, which is now a many-to-many relationship.
  • Loading branch information
oliverjwroberts committed Jul 18, 2024
1 parent a640045 commit 2ac9df2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions app/enquiries/common/datahub_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ def dh_prepare_payload(
A ``(payload, 'primary_sector')`` or ``(payload, None)``, where
``payload`` is a ``dict``.
"""
specific_programme_id = resolve_metadata_id(

Check warning on line 567 in app/enquiries/common/datahub_utils.py

View check run for this annotation

Codecov / codecov/patch

app/enquiries/common/datahub_utils.py#L567

Added line #L567 was not covered by tests
enquiry.get_specific_investment_programme_display(),
fetch_metadata("investment-specific-programme"),
)

sector = resolve_metadata_id(
enquiry.get_primary_sector_display(),
Expand Down Expand Up @@ -595,10 +599,8 @@ def dh_prepare_payload(
enquiry.get_investor_involvement_level_display(),
fetch_metadata("investment-involvement"),
),
specific_programme=resolve_metadata_id(
enquiry.get_specific_investment_programme_display(),
fetch_metadata("investment-specific-programme"),
),
# despite only accepting one in EMT, specific_programmes is a many-to-many field in DH API
specific_programmes=[specific_programme_id] if specific_programme_id is not None else [],
client_contacts=[contact_id],
client_relationship_manager=client_relationship_manager_id,
sector=sector,
Expand Down
2 changes: 1 addition & 1 deletion app/enquiries/tests/test_dh_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_dh_request_payload(self, fetch_metadata):
'stage': stage_id,
'investor_type': None,
'level_of_involvement': None,
'specific_programme': None,
'specific_programmes': [],
'client_contacts': [contact_id],
'client_relationship_manager': client_relationship_manager_id,
'sector': sector_id,
Expand Down

0 comments on commit 2ac9df2

Please sign in to comment.