本文整理汇总了Python中sixpack.models.Experiment.pause方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.pause方法的具体用法?Python Experiment.pause怎么用?Python Experiment.pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sixpack.models.Experiment
的用法示例。
在下文中一共展示了Experiment.pause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all
# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import pause [as 别名]
def test_all(self):
# there are three created in setUp()
all_of_them = Experiment.all(redis=self.redis)
self.assertEqual(len(all_of_them), 3)
exp_1 = Experiment('archive-this', ['archived', 'archived2'], redis=self.redis)
exp_1.save()
# Check if we have 4 active experiments in total
all_again = Experiment.all(redis=self.redis)
self.assertEqual(len(all_again), 4)
# Pause one experiment.
exp_1.pause()
# We should have 1 paused experiment in total
all_paused = Experiment.paused(redis=self.redis)
self.assertEqual(len(all_paused), 1)
# We should have 3 active experiments.
all_active_experiments = Experiment.all(redis=self.redis)
self.assertEqual(len(all_active_experiments), 3)
# Total, with paused and excluding archived should be 4.
all_with_paused = Experiment.all(exclude_paused=False, redis=self.redis)
self.assertEqual(len(all_with_paused), 4)
# Resume the experiment
exp_1.resume()
# We should have 4 active experiments
all_active_experiments = Experiment.all(redis=self.redis)
self.assertEqual(len(all_active_experiments), 4)
# Archive the experiment
exp_1.archive()
all_active_experiments = Experiment.all(redis=self.redis)
self.assertEqual(len(all_active_experiments), 3)
# We should have 1 archived experiment
all_archived = Experiment.archived(redis=self.redis)
self.assertEqual(len(all_archived), 1)
# Total, with archived, excluding paused should be 4
all_with_archived = Experiment.all(exclude_archived=False, redis=self.redis)
self.assertEqual(len(all_with_archived), 4)
示例2: TestExperimentModel
# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import pause [as 别名]
#.........这里部分代码省略.........
with self.assertRaises(ValueError):
Experiment.find_or_create('never-gonna-x', ['let', 'you', 'down', 'give', 'you', 'up'], redis=self.redis)
exp.delete()
Experiment.find_or_create('never-gonna-x', ['let', 'you', 'down', 'give', 'you', 'up'], redis=self.redis)
def test_delete(self):
exp = Experiment('delete-me', self.alternatives, redis=self.redis)
exp.save()
exp.delete()
with self.assertRaises(ValueError):
Experiment.find('delete-me', redis=self.redis)
def test_leaky_delete(self):
exp = Experiment('delete-me-1', self.alternatives, redis=self.redis)
exp.save()
exp2 = Experiment('delete', self.alternatives, redis=self.redis)
exp2.save()
exp2.delete()
exp3 = Experiment.find('delete-me-1', redis=self.redis)
self.assertEqual(exp3.get_alternative_names(), self.alternatives)
def test_archive(self):
self.assertFalse(self.exp_1.is_archived())
self.exp_1.archive()
self.assertTrue(self.exp_1.is_archived())
def test_pause(self):
self.assertFalse(self.exp_1.is_paused())
self.exp_1.pause()
self.assertTrue(self.exp_1.is_paused())
self.exp_1.resume()
self.assertFalse(self.exp_1.is_paused())
def test_resume(self):
self.exp_1.pause()
self.assertTrue(self.exp_1.is_paused())
self.exp_1.resume()
self.assertFalse(self.exp_1.is_paused())
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)