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


Python Experiment.is_archived方法代码示例

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


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

示例1: test_participate_with_bucket

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import is_archived [as 别名]
    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)
开发者ID:harmoney-dev,项目名称:sixpack,代码行数:13,代码来源:api_test.py

示例2: TestExperimentModel

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import is_archived [as 别名]
class TestExperimentModel(unittest.TestCase):

    unit = True

    def setUp(self):
        self.redis = fakeredis.FakeStrictRedis()
        self.alternatives = ['yes', 'no']

        self.exp_1 = Experiment('show-something-awesome', self.alternatives, redis=self.redis)
        self.exp_2 = Experiment('dales-lagunitas', ['dales', 'lagunitas'], redis=self.redis)
        self.exp_3 = Experiment('mgd-budheavy', ['mgd', 'bud-heavy'], redis=self.redis)
        self.exp_1.save()
        self.exp_2.save()
        self.exp_3.save()

    def test_constructor(self):
        with self.assertRaises(ValueError):
            Experiment('not-enough-args', ['1'], redis=self.redis)

    def test_save(self):
        pass

    def test_control(self):
        control = self.exp_1.control
        self.assertEqual(control.name, 'yes')

    def test_created_at(self):
        exp = Experiment('bench-press', ['joe', 'think'], redis=self.redis)
        date = exp.created_at
        self.assertIsNone(date)
        exp.save()
        date = exp.created_at
        self.assertTrue(isinstance(date, datetime))

    def test_get_alternative_names(self):
        exp = Experiment('show-something', self.alternatives, redis=self.redis)
        names = exp.get_alternative_names()
        self.assertEqual(sorted(self.alternatives), sorted(names))

    def test_is_new_record(self):
        exp = Experiment('show-something-is-new-record', self.alternatives, redis=self.redis)
        self.assertTrue(exp.is_new_record())
        exp.save()
        self.assertFalse(exp.is_new_record())

    # fakeredis does not currently support bitcount
    # todo, fix fakeredis and
    def _test_total_participants(self):
        pass

    def _test_total_conversions(self):
        pass

    def test_description(self):
        exp = Experiment.find_or_create('never-gonna', ['give', 'you', 'up'], redis=self.redis)
        self.assertEqual(exp.description, None)

        exp.update_description('hallo')
        self.assertEqual(exp.description, 'hallo')

    def test_change_alternatives(self):
        exp = Experiment.find_or_create('never-gonna-x', ['let', 'you', 'down'], redis=self.redis)

        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())
        self.exp_1.unarchive()
        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()
#.........这里部分代码省略.........
开发者ID:VPilitsyn,项目名称:sixpack,代码行数:103,代码来源:experiment_model_test.py

示例3: TestExperimentModel

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import is_archived [as 别名]
class TestExperimentModel(unittest.TestCase):

    unit = True

    def setUp(self):
        self.redis = fakeredis.FakeStrictRedis()
        self.alternatives = ["yes", "no"]

        self.exp_1 = Experiment("show-something-awesome", self.alternatives, self.redis)
        self.exp_2 = Experiment("dales-lagunitas", ["dales", "lagunitas"], self.redis)
        self.exp_3 = Experiment("mgd-budheavy", ["mgd", "bud-heavy"], self.redis)
        self.exp_1.save()
        self.exp_2.save()
        self.exp_3.save()

    def test_constructor(self):
        with self.assertRaises(ValueError):
            Experiment("not-enough-args", ["1"], self.redis)

    def test_save(self):
        pass

    def test_control(self):
        control = self.exp_1.control
        self.assertEqual(control.name, "yes")

    def test_created_at(self):
        exp = Experiment("bench-press", ["joe", "think"], self.redis)
        date = exp.created_at()
        self.assertIsNone(date)
        exp.save()
        date = exp.created_at()
        self.assertTrue(isinstance(date, datetime))

    def test_get_alternative_names(self):
        exp = Experiment("show-something", self.alternatives, self.redis)
        names = exp.get_alternative_names()
        self.assertEqual(sorted(self.alternatives), sorted(names))

    def test_is_new_record(self):
        exp = Experiment("show-something-is-new-record", self.alternatives, self.redis)
        self.assertTrue(exp.is_new_record())
        exp.save()
        self.assertFalse(exp.is_new_record())

    # fakeredis does not currently support bitcount
    # todo, fix fakeredis and
    def _test_total_participants(self):
        pass

    def _test_total_conversions(self):
        pass

    def test_description(self):
        exp = Experiment.find_or_create("never-gonna", ["give", "you", "up"], self.redis)
        self.assertEqual(exp.get_description(), None)

        exp.update_description("hallo")
        self.assertEqual(exp.get_description(), "hallo")

    def test_change_alternatives(self):
        exp = Experiment.find_or_create("never-gonna-x", ["let", "you", "down"], self.redis)

        with self.assertRaises(ValueError):
            Experiment.find_or_create("never-gonna-x", ["let", "you", "down", "give", "you", "up"], self.redis)

        exp.delete()

        Experiment.find_or_create("never-gonna-x", ["let", "you", "down", "give", "you", "up"], self.redis)

    def test_delete(self):
        exp = Experiment("delete-me", self.alternatives, self.redis)
        exp.save()

        exp.delete()
        with self.assertRaises(ValueError):
            Experiment.find("delete-me", self.redis)

    def test_leaky_delete(self):
        exp = Experiment("delete-me-1", self.alternatives, self.redis)
        exp.save()

        exp2 = Experiment("delete", self.alternatives, self.redis)
        exp2.save()

        exp2.delete()
        exp3 = Experiment.find("delete-me-1", 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())
        self.exp_1.unarchive()
        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()
#.........这里部分代码省略.........
开发者ID:spil-bahadir,项目名称:sixpack,代码行数:103,代码来源:experiment_model_test.py

示例4: TestExperimentModel

# 需要导入模块: from sixpack.models import Experiment [as 别名]
# 或者: from sixpack.models.Experiment import is_archived [as 别名]
class TestExperimentModel(unittest.TestCase):

    unit = True

    def setUp(self):
        self.redis = fakeredis.FakeStrictRedis()
        self.alternatives = ['yes', 'no']

        self.exp_1 = Experiment('show-something-awesome', self.alternatives, redis=self.redis)
        self.exp_2 = Experiment('dales-lagunitas', ['dales', 'lagunitas'], redis=self.redis)
        self.exp_3 = Experiment('mgd-budheavy', ['mgd', 'bud-heavy'], redis=self.redis)
        self.exp_1.save()
        self.exp_2.save()
        self.exp_3.save()

    def tearDown(self):
        pipe = self.redis.pipeline()
        pipe.flushdb()
        pipe.execute()

    def test_constructor(self):
        with self.assertRaises(ValueError):
            Experiment('not-enough-args', ['1'], redis=self.redis)

    def test_save(self):
        pass

    def test_control(self):
        control = self.exp_1.control
        self.assertEqual(control.name, 'yes')

    def test_created_at(self):
        exp = Experiment('bench-press', ['joe', 'think'], redis=self.redis)
        date = exp.created_at
        self.assertIsNone(date)
        exp.save()
        date = exp.created_at
        self.assertTrue(isinstance(date, str))

    def test_get_alternative_names(self):
        exp = Experiment('show-something', self.alternatives, redis=self.redis)
        names = exp.get_alternative_names()
        self.assertEqual(sorted(self.alternatives), sorted(names))

    def test_is_new_record(self):
        exp = Experiment('show-something-is-new-record', self.alternatives, redis=self.redis)
        self.assertTrue(exp.is_new_record())
        exp.save()
        self.assertFalse(exp.is_new_record())

    # fakeredis does not currently support bitcount
    # todo, fix fakeredis and
    def _test_total_participants(self):
        pass

    def _test_total_conversions(self):
        pass

    def test_description(self):
        exp = Experiment.find_or_create('never-gonna', ['give', 'you', 'up'], redis=self.redis)
        self.assertEqual(exp.description, None)

        exp.update_description('hallo')
        self.assertEqual(exp.description, 'hallo')

    def test_change_alternatives(self):
        exp = Experiment.find_or_create('never-gonna-x', ['let', 'you', 'down'], redis=self.redis)

        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())
        self.exp_1.unarchive()
        self.assertFalse(self.exp_1.is_archived())
#.........这里部分代码省略.........
开发者ID:BigR-Lab,项目名称:sixpack,代码行数:103,代码来源:experiment_model_test.py


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