Skip to content

Commit

Permalink
Rework handling tahoe_dip user_sync receiver in tests
Browse files Browse the repository at this point in the history
Just patch with a no-op
  • Loading branch information
bryanlandia committed Jun 27, 2023
1 parent 1910b2e commit a231332
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
5 changes: 0 additions & 5 deletions openedx/core/djangoapps/appsembler/tahoe_idp/tests/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from django.urls import reverse
from django.contrib.auth import get_user_model
from django.test import override_settings
from rest_framework.test import APITestCase
from rest_framework import status

Expand Down Expand Up @@ -65,12 +64,12 @@ def deactivate_user(self, color, username=None):
})
return response

@patch('tahoe_idp.receivers.user_sync_to_idp') # no-op
@patch('tahoe_idp.api.get_tahoe_idp_id_by_user')
@patch('tahoe_idp.api.deactivate_user')
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_TAHOE_IDP': True})
@override_settings(TAHOE_IDP_CONFIGS={'API_KEY':'fake', 'BASE_URL': 'http://localhost'})
def test_disallow_email_reuse_after_deactivate(
self, mock_deactivate_user, mock_get_tahoe_idp_id_by_user
self, mock_deactivate_user, mock_get_tahoe_idp_id_by_user, mock_user_sync_to_idp
):
"""
Test the account deletion with Tahoe IdP support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from django.conf import settings
from django.core import mail
from django.test import override_settings, RequestFactory, TestCase
from django.test import RequestFactory, TestCase
from unittest.mock import Mock, patch
from openedx.core.djangoapps.user_authn.views.password_reset import password_reset
from openedx.core.djangolib.testing.utils import skip_unless_lms
Expand All @@ -16,14 +16,14 @@

@ddt.ddt
@skip_unless_lms
@patch('tahoe_idp.receivers.user_sync_to_idp') # no-op
@patch('tahoe_idp.api.request_password_reset')
class TahoeIdpResetPasswordTests(TestCase):
"""
Tests that clicking reset works with both Tahoe IdP and non-idp logic.
"""
request_factory = RequestFactory()

@override_settings(TAHOE_IDP_CONFIGS={'API_KEY':'fake', 'BASE_URL': 'http://localhost'})
@ddt.unpack
@ddt.data({
'enable_tahoe_idp': False,
Expand All @@ -32,7 +32,7 @@ class TahoeIdpResetPasswordTests(TestCase):
'enable_tahoe_idp': True,
'message': 'Tahoe 2.0 logic: should NOT send email via Open edX, `tahoe_idp` takes care of that',
})
def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, enable_tahoe_idp, message):
def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, mock_user_sync_to_idp, enable_tahoe_idp, message):
"""
Tests Tahoe IdP/non-idp password reset.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ddt
from mock import patch

from django.test import override_settings
from django.urls import reverse_lazy
from rest_framework import status
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -52,13 +51,13 @@ def test_api_without_tahoe_idp(self, url):
content = response.content.decode('utf-8')
assert response.status_code == status.HTTP_200_OK, '{} {}'.format(color1, content)

@override_settings(TAHOE_IDP_CONFIGS={'API_KEY':'fake', 'BASE_URL': 'http://localhost'})
@patch('tahoe_idp.receivers.user_sync_to_idp') # no-op
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_TAHOE_IDP': True})
@ddt.data(
reverse_lazy('tahoe-api:v1:registrations-list'),
reverse_lazy('tahoe-api:v2:registrations-list'),
)
def test_api_wit_tahoe_idp(self, url):
def test_api_wit_tahoe_idp(self, mock_user_sync_to_idp, url):
"""
Both v1 and v2 API shouldn't work with Tahoe IdP.
"""
Expand Down

0 comments on commit a231332

Please sign in to comment.