Skip to content

Commit 2067caf

Browse files
committed
[AI-FSSDK] [FSSDK-12958] Add test for one local holdout hit on two rules
1 parent 532edfb commit 2067caf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎tests/test_decision_service_holdout.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,25 @@ def test_local_holdout_hits_on_several_rules_send_several_holdout_events(self):
17741774
self.assertEqual(final_call.args[5], str(enums.DecisionSources.ROLLOUT))
17751775
self.assertIsNone(final_call.args[2])
17761776

1777+
def test_one_local_holdout_on_two_rules_sends_two_holdout_events(self):
1778+
"""A single local holdout targeting two rules is hit on each rule and sends an event per hit."""
1779+
opt = self._make_opt_exp_with_rollout([
1780+
_holdout('lh_shared', 'shared', included_rules=['111127', '211147']),
1781+
])
1782+
config = opt.config_manager.get_config()
1783+
1784+
result = self._decision_svc().get_decision_for_flag(
1785+
config.get_feature_from_key('test_feature_in_experiment'), opt.create_user_context('test_user', {}), config
1786+
)
1787+
self.assertEqual([d.experiment.key for d in result['holdout_decisions']], ['shared', 'shared'])
1788+
1789+
with mock.patch.object(opt, '_send_impression_event', wraps=opt._send_impression_event) as mock_send:
1790+
decision = opt.create_user_context('test_user', {}).decide('test_feature_in_experiment')
1791+
1792+
self.assertIsNone(decision.variation_key)
1793+
self.assertEqual(self._holdout_impressions(mock_send), ['shared', 'shared'])
1794+
self.assertEqual(mock_send.call_count, 3)
1795+
17771796
def test_local_holdout_hit_beats_stored_variation_without_profile_save(self):
17781797
"""A sticky stored variation for a held-out rule is not served and the profile is not updated."""
17791798
opt = self._make_opt_exp_with_rollout([_holdout('lh_exp', 'for_exp', included_rules=['111127'])])

0 commit comments

Comments
 (0)