コード例 #1
0
 def test_finished_raises_an_exception_without_db_failover(self):
     self.app.config['SPLIT_DB_FAILOVER'] = False
     (flexmock(Redis)
         .should_receive('execute_command')
         .and_raise(ConnectionError))
     with raises(ConnectionError):
         finished('link_color')
コード例 #2
0
    def test_finished_clears_out_users_participation_from_their_session(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        assert session['split'] == {"link_color": alternative_name}
        finished('link_color')
        assert session['split'] == {}
コード例 #3
0
    def test_finished_clears_out_users_participation_from_their_session(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        assert session['split'] == {"link_color": alternative_name}
        finished('link_color')
        assert session['split'] == {}
コード例 #4
0
 def test_finished_raises_an_exception_without_db_failover(self):
     self.app.config['SPLIT_DB_FAILOVER'] = False
     (flexmock(Redis)
         .should_receive('execute_command')
         .and_raise(ConnectionError))
     with raises(ConnectionError):
         finished('link_color')
コード例 #5
0
 def test_finished_increments_completed_alternative_counter(self):
     Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
     alternative_name = ab_test('link_color', 'blue', 'red')
     alternative = Alternative(self.redis, alternative_name, 'link_color')
     previous_completion_count = alternative.completed_count
     finished('link_color')
     new_completion_count = alternative.completed_count
     assert new_completion_count == previous_completion_count + 1
コード例 #6
0
 def test_finished_increments_completed_alternative_counter(self):
     Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
     alternative_name = ab_test('link_color', 'blue', 'red')
     alternative = Alternative(self.redis, alternative_name, 'link_color')
     previous_completion_count = alternative.completed_count
     finished('link_color')
     new_completion_count = alternative.completed_count
     assert new_completion_count == previous_completion_count + 1
コード例 #7
0
    def test_conversions_return_conversion_rates_for_alternatives(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        alternative = Alternative(self.redis, alternative_name, 'link_color')
        assert alternative.conversion_rate == 0.0

        finished('link_color')

        assert alternative.conversion_rate == 1.0
コード例 #8
0
    def test_finished_dont_incr_completed_twice_if_no_reset(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')

        alternative_name = ab_test('link_color', 'blue', 'red')
        finished('link_color', reset=False)
        finished('link_color', reset=False)

        alternative = Alternative(self.redis, alternative_name, 'link_color')
        completion_count = alternative.completed_count
        assert completion_count == 1
コード例 #9
0
    def test_finished_dont_clear_out_the_users_session_if_reset_is_false(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        assert session['split'] == {"link_color": alternative_name}
        finished('link_color', reset=False)
        assert session['split'] == {
            "link_color": alternative_name,
        }
        assert session['split_finished'] == set(['link_color'])
コード例 #10
0
    def test_finished_clears_test_session_when_version_is_greater_than_0(self):
        experiment = Experiment.find_or_create(self.redis, 'link_color',
                                               'blue', 'red')
        experiment.increment_version()

        alternative_name = ab_test('link_color', 'blue', 'red')
        assert session['split'] == {"link_color:1": alternative_name}

        finished('link_color')
        assert session['split'] == {}
コード例 #11
0
    def test_finished_dont_clear_out_the_users_session_if_reset_is_false(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        assert session['split'] == {"link_color": alternative_name}
        finished('link_color', reset=False)
        assert session['split'] == {
            "link_color": alternative_name,
        }
        assert session['split_finished'] == set(['link_color'])
コード例 #12
0
    def test_conversions_return_conversion_rates_for_alternatives(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')

        alternative = Alternative(self.redis, alternative_name, 'link_color')
        assert alternative.conversion_rate == 0.0

        finished('link_color')

        assert alternative.conversion_rate == 1.0
コード例 #13
0
    def test_finished_dont_incr_completed_twice_if_no_reset(self):
        Experiment.find_or_create(self.redis, 'link_color', 'blue', 'red')

        alternative_name = ab_test('link_color', 'blue', 'red')
        finished('link_color', reset=False)
        finished('link_color', reset=False)

        alternative = Alternative(self.redis, alternative_name, 'link_color')
        completion_count = alternative.completed_count
        assert completion_count == 1
コード例 #14
0
    def test_finished_clears_test_session_when_version_is_greater_than_0(self):
        experiment = Experiment.find_or_create(
            self.redis, 'link_color', 'blue', 'red')
        experiment.increment_version()

        alternative_name = ab_test('link_color', 'blue', 'red')
        assert session['split'] == {"link_color:1": alternative_name}

        finished('link_color')
        assert session['split'] == {}
コード例 #15
0
    def test_only_counts_completion_of_users_on_the_current_version(self):
        experiment = Experiment.find_or_create(
            self.redis, 'link_color', 'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')
        assert session['split'] == {'link_color': alternative_name}
        alternative = Alternative(self.redis, alternative_name, 'link_color')

        experiment.reset()
        assert experiment.version == 1

        finished('link_color')
        alternative = Alternative(self.redis, alternative_name, 'link_color')
        assert alternative.completed_count == 0
コード例 #16
0
    def test_only_counts_completion_of_users_on_the_current_version(self):
        experiment = Experiment.find_or_create(self.redis, 'link_color',
                                               'blue', 'red')
        alternative_name = ab_test('link_color', 'blue', 'red')
        assert session['split'] == {'link_color': alternative_name}
        alternative = Alternative(self.redis, alternative_name, 'link_color')

        experiment.reset()
        assert experiment.version == 1

        finished('link_color')
        alternative = Alternative(self.redis, alternative_name, 'link_color')
        assert alternative.completed_count == 0
コード例 #17
0
 def test_finished_does_nothing_if_experiment_was_not_started_by_the_user(
         self):
     session['split'] = None
     finished('some_experiment_not_started_by_the_user')
コード例 #18
0
ファイル: main.py プロジェクト: databootcampbr/ab-kafka
def buy():
    finished('buy_text')
    return render_template('buy.html')
コード例 #19
0
ファイル: test_extension.py プロジェクト: SvanT/flask-split
 def test_can_serialize_session(self):
     ab_test('link_color', 'blue', 'red')
     finished('link_color')
     self.app.save_session(session, make_response())
コード例 #20
0
 def test_finished_does_nothing_if_experiment_was_not_started_by_the_user(self):
     session['split'] = None
     finished('some_experiment_not_started_by_the_user')
コード例 #21
0
 def test_can_serialize_session(self):
     ab_test('link_color', 'blue', 'red')
     finished('link_color')
     self.app.session_interface.save_session(self.app, session, make_response())
コード例 #22
0
def check_secondary_btn_click():
    finished('secondary_btn_text')
    return render_template('thanks.html')