示例#1
0
 def test_participate_with_client_chosen_alternative(self, mock_find_or_create):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.get_alternative = Mock(return_value=Alternative("yes", exp))
     mock_find_or_create.return_value = exp
     alternative = participate("test", ["no", "yes"], "id1", alternative="yes")
     exp.get_alternative.assert_called_once()
     self.assertEqual("yes", alternative.name)
示例#2
0
 def test_participate(self, mock_find_or_create):
     exp = Experiment("test", ["no", "yes"], winner=None)
     exp.get_alternative = Mock(return_value=Alternative("yes", exp))
     mock_find_or_create.return_value = exp
     alternative = participate("test", ["no", "yes"], "id1")
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)
示例#3
0
    def test_participate_with_bucket(self, mock_find_or_create, mock_record_participation):
        exp = Experiment("test", ["no", "yes"], winner=None)
        exp.is_archived = Mock(return_value=False)
        exp.existing_alternative = Mock(return_value=False)
        exp.is_client_excluded = Mock(return_value=False)
        mock_find_or_create.return_value = exp

        mock_record_participation.return_value = Alternative("no", exp)

        alternative = participate("test", ["no", "yes"], "id1", bucket="no")
        self.assertEqual("no", alternative.name)
示例#4
0
 def test_participate_with_forced_and_record_force_alternative(
         self, mock_find_or_create):
     mock_find_or_create.return_value = Experiment("test", ["no", "yes"],
                                                   winner=None)
     alternative = participate("test", ["no", "yes"],
                               "id1",
                               force="yes",
                               record_force=True,
                               redis=fakeredis.FakeStrictRedis())
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)
示例#5
0
 def test_participate_with_forced_alternative(self, mock_find_or_create):
     mock_find_or_create.return_value = Experiment("test", ["no", "yes"], winner=None)
     alternative = participate("test", ["no", "yes"], "id1", force="yes")
     self.assertEqual("yes", alternative.name)
示例#6
0
 def test_participate_with_forced_and_record_force_alternative(self, mock_find_or_create):
     mock_find_or_create.return_value = Experiment("test", ["no", "yes"], winner=None)
     alternative = participate("test", ["no", "yes"], "id1", force="yes", record_force=True, redis=fakeredis.FakeStrictRedis())
     self.assertEqual("yes", alternative.name)
     self.assertEqual("test", alternative.experiment.name)