Skip to content

Commit

Permalink
fix: patch generate_password in loaded module (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: andrey-canon <[email protected]>
  • Loading branch information
johanseto and andrey-canon authored Jul 22, 2024
1 parent 2703918 commit 8c8306e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions eox_nelp/init_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,20 @@ def patch_generate_password():
with custom nelp `generate_password`.
"""
# pylint: disable=import-outside-toplevel, unused-import
from edx_django_utils import user
from eox_tenant.tenant_wise import set_as_proxy

from eox_nelp.user_authn.utils import generate_password
user.generate_password = generate_password

set_as_proxy(
modules=[
"lms.djangoapps.support.views.manage_user",
"openedx.core.djangoapps.user_api.accounts.utils",
"openedx.core.djangoapps.user_authn.views.auto_auth",
"openedx.core.djangoapps.user_authn.views.register",
],
model="generate_password",
proxy=generate_password
)


def patch_registration_form_factory():
Expand Down
3 changes: 3 additions & 0 deletions eox_nelp/tests/test_init_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class RunInitPipelineTestCase(TestCase):
"""Test class for run_init_pipeline method."""

@patch("eox_nelp.init_pipeline.patch_generate_password")
@patch("eox_nelp.init_pipeline.register_xapi_transformers")
@patch("eox_nelp.init_pipeline.patch_user_gender_choices")
@patch("eox_nelp.init_pipeline.set_mako_templates")
Expand All @@ -26,6 +27,7 @@ def test_pipeline_execute_expected_methods(
set_mako_templates_mock,
patch_user_gender_choices_mock,
register_xapi_transformers_mock,
patch_generate_password_mock,
):
""" Test that method calls the expected methods during the pipeline execution.
Expand All @@ -38,6 +40,7 @@ def test_pipeline_execute_expected_methods(
set_mako_templates_mock.assert_called_once()
patch_user_gender_choices_mock.assert_called_once()
register_xapi_transformers_mock.assert_called_once()
patch_generate_password_mock.assert_called_once()


class SetMakoTemplatesTestCase(TestCase):
Expand Down

0 comments on commit 8c8306e

Please sign in to comment.