Skip to content

Commit 5b58d8d

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 <[email protected]> Co-authored-by: Feanil Patel <[email protected]>
1 parent 65c8cdf commit 5b58d8d

2 files changed

Lines changed: 1 addition & 35 deletions

File tree

common/djangoapps/third_party_auth/tests/test_settings.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,3 @@ def test_social_auth_clean_usernames_default(self):
6868
# Note: SOCIAL_AUTH_CLEAN_USERNAMES is a Derived setting, computed at settings load time.
6969
# This test verifies the default behavior (unicode usernames disabled).
7070
assert settings.SOCIAL_AUTH_CLEAN_USERNAMES is True
71-
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
@@ -332,7 +332,7 @@
332332

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

338338
# Social auth pipeline for third-party authentication.

0 commit comments

Comments
 (0)