@@ -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
0 commit comments