def test_can_participate_in_many_experiments_with_allow_multiple_experiments(self): self.app.config['SPLIT_ALLOW_MULTIPLE_EXPERIMENTS'] = True link_color = ab_test('link_color', 'blue', 'red') button_size = ab_test('button_size', 'small', 'big') assert _get_session()['button_size'] == button_size button_size_alt = Alternative(self.redis, button_size, 'button_size') assert button_size_alt.participant_count == 1
def test_ab_test_only_lets_user_participate_in_one_experiment(self): ab_test('link_color', 'blue', 'red') ab_test('button_size', 'small', 'big') assert _get_session()['button_size'] == 'small' big = Alternative(self.redis, 'big', 'button_size') assert big.participant_count == 0 small = Alternative(self.redis, 'small', 'button_size') assert small.participant_count == 0
def test_ab_test_allows_the_share_of_visitors_see_an_alternative(self): ab_test('link_color', ('blue', 0.8), ('red', 20)) assert _get_session()['link_color'] in ['red', 'blue']
def test_ab_test_assigns_random_alternative_to_a_new_user(self): ab_test('link_color', 'blue', 'red') assert _get_session()['link_color'] in ['red', 'blue']