diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b65dabd5e5..10a037bb0d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,10 @@ Unreleased ---------- * nothing unreleased +[4.18.2] +-------- +* fix: update enterprise model lookup in removal email task + [4.18.1] -------- * chore: debugging log lines diff --git a/enterprise/__init__.py b/enterprise/__init__.py index 4336018c00..512be590f0 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "4.18.1" +__version__ = "4.18.2" diff --git a/enterprise/tasks.py b/enterprise/tasks.py index 7a3d11ad02..a7b3760c6c 100644 --- a/enterprise/tasks.py +++ b/enterprise/tasks.py @@ -376,7 +376,7 @@ def send_group_membership_removal_notification(enterprise_customer_uuid, members ] = enterprise_catalog_client.get_catalog_content_count(catalog_uuid) pecu_emails = [] user_id_by_email = {} - membership_records = enterprise_group_membership_model().objects.filter(uuid__in=membership_uuids) + membership_records = enterprise_group_membership_model().all_objects.filter(uuid__in=membership_uuids) for group_membership in membership_records: if group_membership.pending_enterprise_customer_user is not None: pecu_emails.append(group_membership.pending_enterprise_customer_user.user_email) diff --git a/tests/test_enterprise/api/test_views.py b/tests/test_enterprise/api/test_views.py index c656264d8d..de06a0498c 100644 --- a/tests/test_enterprise/api/test_views.py +++ b/tests/test_enterprise/api/test_views.py @@ -8084,12 +8084,17 @@ def test_successful_remove_learners_from_group(self, mock_send_group_membership_ membership = EnterpriseGroupMembershipFactory(group=self.group_2) memberships_to_delete.append(membership) existing_emails.append(membership.enterprise_customer_user.user.email) - - request_data = {'learner_emails': existing_emails} + catalog_uuid = uuid.uuid4() + request_data = {'learner_emails': existing_emails, 'catalog_uuid': catalog_uuid} response = self.client.post(url, data=request_data) assert response.status_code == 200 assert response.data == {'records_deleted': 10} assert mock_send_group_membership_removal_notification.call_count == 1 + mock_send_group_membership_removal_notification.assert_called_once_with( + self.enterprise_customer.uuid, + [membership.uuid for membership in reversed(memberships_to_delete)], + catalog_uuid, + ) for membership in memberships_to_delete: assert EnterpriseGroupMembership.all_objects.get(pk=membership.pk).status == 'removed' assert EnterpriseGroupMembership.all_objects.get(pk=membership.pk).removed_at diff --git a/tests/test_enterprise/test_tasks.py b/tests/test_enterprise/test_tasks.py index 9ac2c5da46..905e26299e 100644 --- a/tests/test_enterprise/test_tasks.py +++ b/tests/test_enterprise/test_tasks.py @@ -273,17 +273,19 @@ def test_send_group_membership_removal_notification(self, mock_braze_api_client, """ Verify send_group_membership_removal_notification hits braze client with expected args """ - EnterpriseGroupMembershipFactory( + pecu_membership = EnterpriseGroupMembershipFactory( group=self.enterprise_group, pending_enterprise_customer_user=self.pending_enterprise_customer_user, enterprise_customer_user=None, ) - EnterpriseGroupMembershipFactory( + ecu_membership = EnterpriseGroupMembershipFactory( group=self.enterprise_group, pending_enterprise_customer_user=None, enterprise_customer_user__enterprise_customer=self.enterprise_customer, activated_at=datetime.now() ) + pecu_membership.delete() + ecu_membership.delete() admin_email = 'edx@example.org' mock_braze_api_client().create_recipients.return_value = { self.user.email: { @@ -315,7 +317,7 @@ def test_send_group_membership_removal_notification(self, mock_braze_api_client, mock_catalog_content_count = 5 mock_enterprise_catalog_client().get_catalog_content_count.return_value = ( mock_catalog_content_count) - membership_uuids = EnterpriseGroupMembership.objects.values_list('uuid', flat=True) + membership_uuids = EnterpriseGroupMembership.all_objects.values_list('uuid', flat=True) catalog_uuid = uuid.uuid4() send_group_membership_removal_notification( self.enterprise_customer.uuid,