本文整理汇总了Python中flask_split.models.Experiment.save方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.save方法的具体用法?Python Experiment.save怎么用?Python Experiment.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_split.models.Experiment
的用法示例。
在下文中一共展示了Experiment.save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_know_if_it_is_the_control_of_an_experiment
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_know_if_it_is_the_control_of_an_experiment(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
alternative = Alternative(self.redis, 'Basket', 'basket_text')
assert alternative.is_control
alternative = Alternative(self.redis, 'Cart', 'basket_text')
assert not alternative.is_control
示例2: test_increment_completed_count
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_increment_completed_count(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', "Cart")
experiment.save()
alternative = Alternative(self.redis, 'Basket', 'basket_text')
old_completed_count = alternative.participant_count
alternative.increment_completion()
assert alternative.completed_count == old_completed_count + 1
示例3: test_saves_the_start_time_to_redis
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_saves_the_start_time_to_redis(self):
experiment_start_time = datetime(2012, 3, 9, 22, 01, 34)
(flexmock(Experiment)
.should_receive('_get_time')
.and_return(experiment_start_time))
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
assert experiment.start_time == experiment_start_time
示例4: test_handles_not_having_a_start_time
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_handles_not_having_a_start_time(self):
experiment_start_time = datetime(2012, 3, 9, 22, 01, 34)
(flexmock(Experiment)
.should_receive('_get_time')
.and_return(experiment_start_time))
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
self.redis.hdel('experiment_start_times', experiment.name)
assert experiment.start_time is None
示例5: test_reset_an_experiment_if_loaded_with_different_alternatives
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_reset_an_experiment_if_loaded_with_different_alternatives(self):
experiment = Experiment(
self.redis, 'link_color', 'blue', 'red', 'green')
experiment.save()
blue = Alternative(self.redis, 'blue', 'link_color')
blue.participant_count = 5
blue.save()
same_experiment = Experiment.find_or_create(
self.redis, 'link_color', 'blue', 'yellow', 'orange')
alternative_names = [a.name for a in same_experiment.alternatives]
assert alternative_names == ['blue', 'yellow', 'orange']
new_blue = Alternative(self.redis, 'blue', 'link_color')
assert new_blue.participant_count == 0
示例6: test_z_score_is_none_when_the_control_has_no_participations
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_z_score_is_none_when_the_control_has_no_participations(self):
experiment = Experiment(self.redis, 'link_color', 'blue', 'red')
experiment.save()
alternative = Alternative(self.redis, 'red', 'link_color')
assert alternative.z_score is None
示例7: test_belong_to_an_experiment
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_belong_to_an_experiment(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
alternative = Alternative(self.redis, 'Basket', 'basket_text')
assert alternative.experiment.name == experiment.name
示例8: test_control_is_the_first_alternative
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_control_is_the_first_alternative(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
assert experiment.control.name == 'Basket'
示例9: test_find_returns_an_existing_experiment
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_find_returns_an_existing_experiment(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
assert Experiment.find(self.redis, 'basket_text').name == 'basket_text'
示例10: test_is_new_record_knows_if_it_has_been_saved_yet
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_is_new_record_knows_if_it_has_been_saved_yet(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
assert not experiment.is_new_record
示例11: test_deleting_should_delete_itself
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_deleting_should_delete_itself(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
experiment.delete()
assert 'basket_text' not in self.redis
示例12: test_does_not_create_duplicates_when_saving_multiple_times
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_does_not_create_duplicates_when_saving_multiple_times(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
experiment.save()
assert 'basket_text' in self.redis
assert self.redis.lrange('basket_text', 0, -1) == ['Basket', 'Cart']
示例13: test_saves_to_redis
# 需要导入模块: from flask_split.models import Experiment [as 别名]
# 或者: from flask_split.models.Experiment import save [as 别名]
def test_saves_to_redis(self):
experiment = Experiment(self.redis, 'basket_text', 'Basket', 'Cart')
experiment.save()
assert 'basket_text' in self.redis