-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: DB tx isolation and informative license logging
Track license changes in a celery task outside of the DB transaction block that updates the license state, so that task can read the committed updates to the license records. Also add helpful logging to our license assignment/reminder email tasks. ENT-7795
- Loading branch information
1 parent
b6fe564
commit 3790e16
Showing
3 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,12 +105,20 @@ def test_activation_task(self, mock_braze_client, mock_enterprise_client): | |
'contact_email': self.contact_email, | ||
} | ||
|
||
# Add an extra recipient with no associated license | ||
# to hit debug-logging test coverage | ||
tasks.send_assignment_email_task( | ||
self.custom_template_text, | ||
self.email_recipient_list, | ||
self.email_recipient_list + ['[email protected]'], | ||
self.subscription_plan.uuid, | ||
) | ||
|
||
called_emails = [ | ||
_call.kwargs['recipients'][0]['attributes']['email'] | ||
for _call in mock_braze_client().send_campaign_message.call_args_list | ||
] | ||
self.assertNotIn('[email protected]', called_emails) | ||
|
||
for user_email in self.email_recipient_list: | ||
expected_license_key = str(self.subscription_plan.licenses.get( | ||
user_email=user_email | ||
|
@@ -179,12 +187,20 @@ def test_send_reminder_email_task(self, mock_enterprise_client, mock_braze_clien | |
'contact_email': self.contact_email, | ||
} | ||
with freeze_time(localized_utcnow()): | ||
# Add an extra recipient with no associated license | ||
# to hit debug-logging test coverage | ||
tasks.send_reminder_email_task( | ||
self.custom_template_text, | ||
self.email_recipient_list, | ||
self.email_recipient_list + ['[email protected]'], | ||
self.subscription_plan.uuid | ||
) | ||
|
||
called_emails = [ | ||
_call.kwargs['recipients'][0]['attributes']['email'] | ||
for _call in mock_braze_client().send_campaign_message.call_args_list | ||
] | ||
self.assertNotIn('[email protected]', called_emails) | ||
|
||
for user_email in self.email_recipient_list: | ||
expected_license_key = str(self.subscription_plan.licenses.get( | ||
user_email=user_email | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters