diff --git a/license_manager/apps/api/tasks.py b/license_manager/apps/api/tasks.py index d29b0d22..962f9aac 100644 --- a/license_manager/apps/api/tasks.py +++ b/license_manager/apps/api/tasks.py @@ -29,7 +29,10 @@ REVOCABLE_LICENSE_STATUSES, NotificationChoices, ) -from license_manager.apps.subscriptions.event_utils import track_license_changes +from license_manager.apps.subscriptions.event_utils import ( + get_license_tracking_properties, + track_license_changes, +) from license_manager.apps.subscriptions.models import ( CustomerAgreement, License, @@ -222,6 +225,7 @@ def send_reminder_email_task(custom_template_text, email_recipient_list, subscri 'enterprise_contact_email': enterprise_contact_email, } recipient = _aliased_recipient_object_from_email(user_email) + recipient['attributes'].update(get_license_tracking_properties(pending_license)) try: braze_client_instance = BrazeApiClient() diff --git a/license_manager/apps/api/tests/test_tasks.py b/license_manager/apps/api/tests/test_tasks.py index bd61014f..d3a10d52 100644 --- a/license_manager/apps/api/tests/test_tasks.py +++ b/license_manager/apps/api/tests/test_tasks.py @@ -26,6 +26,9 @@ UNASSIGNED, NotificationChoices, ) +from license_manager.apps.subscriptions.event_utils import ( + get_license_tracking_properties, +) from license_manager.apps.subscriptions.exceptions import LicenseRevocationError from license_manager.apps.subscriptions.models import ( CustomerAgreement, @@ -202,9 +205,10 @@ def test_send_reminder_email_task(self, mock_enterprise_client, mock_braze_clien self.assertNotIn('no-license@foo.com', called_emails) for user_email in self.email_recipient_list: - expected_license_key = str(self.subscription_plan.licenses.get( + expected_license = self.subscription_plan.licenses.get( user_email=user_email - ).activation_key) + ) + expected_license_key = str(expected_license.activation_key) mock_enterprise_client().get_enterprise_customer_data.assert_any_call( self.subscription_plan.enterprise_customer_uuid ) @@ -229,6 +233,7 @@ def test_send_reminder_email_task(self, mock_enterprise_client, mock_braze_clien 'alias_name': user_email, }, } + expected_recipient['attributes'].update(get_license_tracking_properties(expected_license)) mock_braze_client().send_campaign_message.assert_any_call( settings.BRAZE_ASSIGNMENT_EMAIL_CAMPAIGN, recipients=[expected_recipient],