From 55be3ff4318c90e44215ee3852f6a3466b0b968e Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Tue, 27 Jun 2023 16:51:22 -0700 Subject: [PATCH] mock user_sync_to_idp receiver in tahoe idp email change tests --- .../tahoe_idp/tests/test_tahoe_idp_email_change.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py index a341cb768e9..8dd1d3af341 100644 --- a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py @@ -3,13 +3,15 @@ """ from django.conf import settings +from django.contrib.auth.models import User from django.core import mail -from django.test import override_settings, TestCase +from django.db.models.signals import post_save +from django.test import TestCase from django.urls import reverse from unittest.mock import patch from openedx.core.djangolib.testing.utils import skip_unless_lms -from student.models import PendingEmailChange +from student.models import PendingEmailChange, UserProfile from student.tests.factories import PendingEmailChangeFactory, UserFactory @@ -37,12 +39,15 @@ def test_successful_email_change_without_idp(self, mock_update_user_email): 'Should not use idp unless explicitly enabled via ENABLE_TAHOE_IDP' ) - @override_settings(TAHOE_IDP_CONFIGS={'API_KEY':'fake', 'BASE_URL': 'http://localhost'}) @patch('tahoe_idp.api.update_user_email') - def test_successful_email_change_with_idp(self, mock_update_user_email): + def test_successful_email_change_with_idp(self, mock_update_user_email, mock_user_sync_to_idp): """ Test `confirm_email_change` with ENABLE_TAHOE_IDP = True. """ + + post_save.connect(mock_user_sync_to_idp, sender=User, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + post_save.connect(mock_user_sync_to_idp, sender=UserProfile, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + with patch.dict(settings.FEATURES, {'ENABLE_TAHOE_IDP': True}): response = self.client.get(reverse('confirm_email_change', args=[self.key]))