@@ -96,31 +96,33 @@ def test_create_user_from_context_user_id_priority(self):
9696 user = DevCycleUser .create_user_from_context (context )
9797 self .assertEqual (user .user_id , userId )
9898
99- def test_create_user_from_context_userId_in_custom_data_when_not_used (self ):
99+ def test_create_user_from_context_user_id_fields_always_excluded (self ):
100100 targeting_key_id = "targeting-12345"
101101 userId = "userId-12345"
102+ user_id = "user_id-12345"
102103
103- # When targeting_key is used, userId should be in custom data
104+ # When targeting_key is used, both user_id and userId should be excluded from custom data
104105 context = EvaluationContext (
105106 targeting_key = targeting_key_id ,
106- attributes = {"userId" : userId , "other_field" : "value" }
107+ attributes = {"user_id" : user_id , " userId" : userId , "other_field" : "value" }
107108 )
108109 user = DevCycleUser .create_user_from_context (context )
109110 self .assertEqual (user .user_id , targeting_key_id )
110111 self .assertIsNotNone (user .customData )
111- self .assertEqual (user .customData ["userId" ], userId )
112+ self .assertNotIn ("user_id" , user .customData )
113+ self .assertNotIn ("userId" , user .customData )
112114 self .assertEqual (user .customData ["other_field" ], "value" )
113115
114- # When user_id is used, userId should be in custom data
115- user_id = "user_id-12345"
116+ # When user_id is used, userId should still be excluded from custom data
116117 context = EvaluationContext (
117118 targeting_key = None ,
118119 attributes = {"user_id" : user_id , "userId" : userId , "other_field" : "value" }
119120 )
120121 user = DevCycleUser .create_user_from_context (context )
121122 self .assertEqual (user .user_id , user_id )
122123 self .assertIsNotNone (user .customData )
123- self .assertEqual (user .customData ["userId" ], userId )
124+ self .assertNotIn ("user_id" , user .customData )
125+ self .assertNotIn ("userId" , user .customData )
124126 self .assertEqual (user .customData ["other_field" ], "value" )
125127
126128 def test_create_user_from_context_userId_excluded_when_used (self ):
0 commit comments