Skip to content

Commit 07b8692

Browse files
committed
updating log message
1 parent a37540a commit 07b8692

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

optimizely/decision_service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,17 @@ def get_variation_for_rollout(self, rollout, user_id, attributes=None, ignore_us
190190
return variation
191191
else:
192192
# Evaluate no further rules
193+
self.logger.log(enums.LogLevels.DEBUG,
194+
'User "%s" is not in the traffic group for the targeting else. '
195+
'Checking "Everyone Else" rule now.' % user_id)
193196
break
194197

195-
# Evaluate last rule
198+
# Evaluate last rule i.e. "Everyone Else" rule
199+
everyone_else_experiment = rollout.experiments[-1]
196200
if audience_helper.is_user_in_experiment(self.config,
197201
self.config.get_experiment_from_key(rollout.experiments[-1].get('key')),
198202
attributes):
199-
variation = self.bucketer.bucket(rollout.experiments[-1], user_id)
203+
variation = self.bucketer.bucket(everyone_else_experiment, user_id)
200204
if variation:
201205
self.logger.log(enums.LogLevels.DEBUG,
202206
'User "%s" meets conditions for targeting rule "Everyone Else".' % user_id)

tests/test_decision_service.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ def test_get_variation__ignore_user_profile_when_specified(self):
331331

332332
def test_get_variation_for_feature__returns_variation_for_feature_in_experiment(self):
333333
""" Test that get_variation_for_feature returns the variation of the experiment the feature is associated with. """
334+
334335
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
335336
project_config = opt_obj.config
336337
decision_service = opt_obj.decision_service
@@ -349,6 +350,7 @@ def test_get_variation_for_feature__returns_variation_for_feature_in_experiment(
349350
def test_get_variation_for_feature__returns_variation_for_feature_in_rollout(self):
350351
""" Test that get_variation_for_feature returns the variation of
351352
the experiment in the rollout that the user is bucketed into. """
353+
352354
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
353355
project_config = opt_obj.config
354356
decision_service = opt_obj.decision_service
@@ -364,6 +366,7 @@ def test_get_variation_for_feature__returns_variation_for_feature_in_rollout(sel
364366
def test_get_variation_for_feature__returns_variation_if_user_not_in_experiment_but_in_rollout(self):
365367
""" Test that get_variation_for_feature returns the variation of the experiment in the
366368
feature's rollout even if the user is not bucketed into the feature's experiment. """
369+
367370
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
368371
project_config = opt_obj.config
369372
decision_service = opt_obj.decision_service
@@ -383,6 +386,7 @@ def test_get_variation_for_feature__returns_variation_if_user_not_in_experiment_
383386
def test_get_variation_for_feature__returns_variation_for_feature_in_group(self):
384387
""" Test that get_variation_for_feature returns the variation of
385388
the experiment the user is bucketed in the feature's group. """
389+
386390
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
387391
project_config = opt_obj.config
388392
decision_service = opt_obj.decision_service
@@ -402,6 +406,7 @@ def test_get_variation_for_feature__returns_variation_for_feature_in_group(self)
402406
def test_get_variation_for_feature__returns_none_for_user_not_in_group(self):
403407
""" Test that get_variation_for_feature returns None for
404408
user not in group and the feature is not part of a rollout. """
409+
405410
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
406411
project_config = opt_obj.config
407412
decision_service = opt_obj.decision_service
@@ -418,6 +423,7 @@ def test_get_variation_for_feature__returns_none_for_user_not_in_group(self):
418423

419424
def test_get_variation_for_feature__returns_none_for_user_not_in_experiment(self):
420425
""" Test that get_variation_for_feature returns None for user not in the associated experiment. """
426+
421427
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
422428
project_config = opt_obj.config
423429
decision_service = opt_obj.decision_service
@@ -434,6 +440,7 @@ def test_get_variation_for_feature__returns_none_for_user_not_in_experiment(self
434440

435441
def test_get_variation_for_feature__returns_none_for_user_not_in_rollout(self):
436442
""" Test that get_variation_for_feature returns None for the user not in the associated rollout. """
443+
437444
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
438445
project_config = opt_obj.config
439446
decision_service = opt_obj.decision_service
@@ -451,6 +458,7 @@ def test_get_variation_for_feature__returns_none_for_user_not_in_rollout(self):
451458
def test_get_variation_for_feature__returns_none_for_user_in_group_but_experiment_not_associated_with_feature(self):
452459
""" Test that if a user is in the mutex group but the experiment is
453460
not targeting a feature, then None is returned. """
461+
454462
opt_obj = optimizely.Optimizely(json.dumps(self.config_dict_with_features))
455463
project_config = opt_obj.config
456464
decision_service = opt_obj.decision_service

0 commit comments

Comments
 (0)