Skip to content

Commit 68f2ff2

Browse files
fix: Apply suggestions from code review
Don't add a new reference to the old FEATURES dictionary and drop an unncessary test. Co-authored-by: Taylor Payne <taylor.payne2@wgu.edu> Co-authored-by: Feanil Patel <feanil@axim.org>
1 parent 6058ade commit 68f2ff2

2 files changed

Lines changed: 1 addition & 34 deletions

File tree

common/djangoapps/third_party_auth/tests/test_settings.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,36 +69,3 @@ def test_social_auth_clean_usernames_default(self):
6969
# This test verifies the default behavior (unicode usernames disabled).
7070
assert settings.SOCIAL_AUTH_CLEAN_USERNAMES is True
7171

72-
def test_social_auth_clean_usernames_computation(self):
73-
"""
74-
Verify the SOCIAL_AUTH_CLEAN_USERNAMES computation logic.
75-
76-
SOCIAL_AUTH_CLEAN_USERNAMES is a Derived setting that is computed at settings load time,
77-
so we can't use @override_settings to test both cases. Instead, we test the computation
78-
logic directly to ensure it correctly inverts the ENABLE_UNICODE_USERNAME feature flag.
79-
"""
80-
# The logic in lms/envs/common.py is:
81-
# SOCIAL_AUTH_CLEAN_USERNAMES = Derived(
82-
# lambda settings: not settings.FEATURES.get('ENABLE_UNICODE_USERNAME', False)
83-
# )
84-
# We replicate and test that logic here.
85-
86-
class FakeSettings:
87-
"""Fake settings object for testing the Derived computation."""
88-
def __init__(self, features):
89-
self.FEATURES = features
90-
91-
# When ENABLE_UNICODE_USERNAME is False (default), SOCIAL_AUTH_CLEAN_USERNAMES should be True
92-
fake_settings = FakeSettings({'ENABLE_UNICODE_USERNAME': False})
93-
result = not fake_settings.FEATURES.get('ENABLE_UNICODE_USERNAME', False)
94-
assert result is True
95-
96-
# When ENABLE_UNICODE_USERNAME is True, SOCIAL_AUTH_CLEAN_USERNAMES should be False
97-
fake_settings = FakeSettings({'ENABLE_UNICODE_USERNAME': True})
98-
result = not fake_settings.FEATURES.get('ENABLE_UNICODE_USERNAME', False)
99-
assert result is False
100-
101-
# When ENABLE_UNICODE_USERNAME is not set, should default to False, so result is True
102-
fake_settings = FakeSettings({})
103-
result = not fake_settings.FEATURES.get('ENABLE_UNICODE_USERNAME', False)
104-
assert result is True

lms/envs/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331

332332
# Computed setting: disable clean usernames check when unicode usernames are enabled
333333
SOCIAL_AUTH_CLEAN_USERNAMES = Derived(
334-
lambda settings: not settings.FEATURES.get('ENABLE_UNICODE_USERNAME', False)
334+
lambda settings: not settings.ENABLE_UNICODE_USERNAME
335335
)
336336

337337
# Social auth pipeline for third-party authentication.

0 commit comments

Comments
 (0)