当前位置: 首页>>代码示例>>Python>>正文


Python Experiment.key方法代码示例

本文整理汇总了Python中sixpack.models.Experiment.key方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.key方法的具体用法?Python Experiment.key怎么用?Python Experiment.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sixpack.models.Experiment的用法示例。


在下文中一共展示了Experiment.key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_key

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import key [as 别名]
    def test_key(self):
        key = self.exp_1.key()
        self.assertEqual(key, 'sxp:e:show-something-awesome')

        key_2 = self.exp_2.key()
        self.assertEqual(key_2, 'sxp:e:dales-lagunitas')

        exp = Experiment('brews', ['mgd', 'bud-heavy'], redis=self.redis)
        key_3 = exp.key()
        self.assertEqual(key_3, 'sxp:e:brews')
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:12,代码来源:experiment_model_test.py

示例2: test_key

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import key [as 别名]
    def test_key(self):
        key = self.exp_1.key()
        self.assertEqual(key, "sxp:e:show-something-awesome")

        key_2 = self.exp_2.key()
        self.assertEqual(key_2, "sxp:e:dales-lagunitas")

        exp = Experiment("brews", ["mgd", "bud-heavy"], self.redis)
        key_3 = exp.key()
        self.assertEqual(key_3, "sxp:e:brews")
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:12,代码来源:experiment_model_test.py

示例3: TestExperimentModel

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import key [as 别名]

#.........这里部分代码省略.........
        self.assertFalse(self.exp_1.is_archived())

    def test_unarchive(self):
        self.exp_1.archive()
        self.assertTrue(self.exp_1.is_archived())
        self.exp_1.unarchive()
        self.assertFalse(self.exp_1.is_archived())

    def test_set_winner(self):
        exp = Experiment('test-winner', ['1', '2'], redis=self.redis)
        exp.set_winner('1')
        self.assertTrue(exp.winner is not None)

        exp.set_winner('1')
        self.assertEqual(exp.winner.name, '1')

    def test_winner(self):
        exp = Experiment.find_or_create('test-get-winner', ['1', '2'], redis=self.redis)
        self.assertIsNone(exp.winner)

        exp.set_winner('1')
        self.assertEqual(exp.winner.name, '1')

    def test_reset_winner(self):
        exp = Experiment('show-something-reset-winner', self.alternatives, redis=self.redis)
        exp.save()
        exp.set_winner('yes')
        self.assertTrue(exp.winner is not None)
        self.assertEqual(exp.winner.name, 'yes')

        exp.reset_winner()
        self.assertIsNone(exp.winner)

    def test_winner_key(self):
        exp = Experiment.find_or_create('winner-key', ['win', 'lose'], redis=self.redis)
        self.assertEqual(exp._winner_key, "{0}:winner".format(exp.key()))

    def test_get_alternative(self):
        client = Client(10, redis=self.redis)

        exp = Experiment.find_or_create('archived-control', ['w', 'l'], redis=self.redis)
        exp.archive()

        # should return control on archived test with no winner
        alt = exp.get_alternative(client)
        self.assertEqual(alt.name, 'w')

        # should return current participation
        exp.unarchive()
        ### HACK TO SKIP WHIPLASH TESTS
        exp.random_sample = 1
        ### HACK TO SKIP WHIPLASH TESTS

        selected_for_client = exp.get_alternative(client)
        self.assertIn(selected_for_client.name, ['w', 'l'])

        # should check to see if client is participating and only return the same alt
        # unsure how to currently test since fakeredis obviously doesn't parse lua
        # most likely integration tests

    # See above note for the next 5 tests
    def _test_existing_alternative(self):
        pass

    def _test_has_converted_by_client(self):
        pass
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:70,代码来源:experiment_model_test.py

示例4: TestExperimentModel

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import key [as 别名]

#.........这里部分代码省略.........
        self.assertFalse(self.exp_1.is_archived())

    def test_unarchive(self):
        self.exp_1.archive()
        self.assertTrue(self.exp_1.is_archived())
        self.exp_1.unarchive()
        self.assertFalse(self.exp_1.is_archived())

    def test_set_winner(self):
        exp = Experiment("test-winner", ["1", "2"], self.redis)
        exp.set_winner("1")
        self.assertTrue(exp.winner is not None)

        exp.set_winner("1")
        self.assertEqual(exp.winner, "1")

    def test_winner(self):
        exp = Experiment.find_or_create("test-get-winner", ["1", "2"], self.redis)
        self.assertIsNone(exp.winner)

        exp.set_winner("1")
        self.assertEqual(exp.winner, "1")

    def test_reset_winner(self):
        exp = Experiment("show-something-reset-winner", self.alternatives, self.redis)
        exp.save()
        exp.set_winner("yes")
        self.assertTrue(exp.winner is not None)
        self.assertEqual(exp.winner, "yes")

        exp.reset_winner()
        self.assertIsNone(exp.winner)

    def test_winner_key(self):
        exp = Experiment.find_or_create("winner-key", ["win", "lose"], self.redis)
        self.assertEqual(exp._winner_key, "{0}:winner".format(exp.key()))

    def test_get_alternative(self):
        client = Client(10, self.redis)

        exp = Experiment.find_or_create("archived-control", ["w", "l"], self.redis)
        exp.archive()

        # should return control on archived test with no winner
        alt = exp.get_alternative(client)
        self.assertEqual(alt.name, "w")

        # should return current participation
        exp.unarchive()
        ### HACK TO SKIP WHIPLASH TESTS
        exp.random_sample = 1
        ### HACK TO SKIP WHIPLASH TESTS

        selected_for_client = exp.get_alternative(client)
        self.assertIn(selected_for_client.name, ["w", "l"])

        # should check to see if client is participating and only return the same alt
        # unsure how to currently test since fakeredis obviously doesn't parse lua
        # most likely integration tests

    # See above note for the next 5 tests
    def _test_existing_alternative(self):
        pass

    def _test_has_converted_by_client(self):
        pass
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:70,代码来源:experiment_model_test.py


注:本文中的sixpack.models.Experiment.key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。