def test_max_cohort(): flush_redis() # check that we can have at the most 3 users in the 'foo' cohort # that cohort is at 100% sampleRate for the fr territory under fr-FR app = get_app() # the counters should all be empty counters = list(dump_counters()) assert len(counters) == 0 # get the cohort 3 times path = '/1/firefox/39/beta/fr-FR/fr/default/default' for i in range(3): res = app.get(path) assert res.json.get('cohort') == 'fooBaz', i # should be exausthed now, let's check we get a default now res = app.get(path) # when default we don't have the cohort key in the response assert 'cohort' not in res.json, res.json # the counters should be 1 for the default, 3 for foo counters = list(dump_counters()) counters.sort() assert counters == ['fr-fr:fr:default:1', 'fr-fr:fr:fooBaz:3']
def test_version_filter(): flush_redis() # check that we are filtering by product app = get_app() # get the cohort for fr-FR+fr path = '/1/firefox/39/beta/fr-FR/fr/default/default' res = app.get(path) assert res.json.get('cohort') == 'fooBaz', res.json # if the version is < 39, we should bypass the foo cohort path = '/1/firefox/38/beta/fr-FR/fr/default/default' res = app.get(path) assert 'cohort' not in res.json, res.json
def test_channel_filter(): flush_redis() # check that we are filtering by product app = get_app() # get the cohort for fr-FR+fr path = '/1/firefox/39/beta/fr-FR/fr/default/default' res = app.get(path) assert res.json.get('cohort') == 'fooBaz', res.json # if the channel is not listed, we should bypass the foo cohort path = '/1/firefox/39/alpha/fr-FR/fr/default/default' res = app.get(path) assert 'cohort' not in res.json, res.json # cdntest should map to regular channel path = '/1/firefox/39/beta-cdntest/fr-FR/fr/default/default' res = app.get(path) assert res.json.get('cohort') == 'fooBaz', res.json # localtest should map to regular channel path = '/1/firefox/39/release-localtest/fr-FR/fr/default/default' res = app.get(path) assert res.json.get('cohort') == 'fooBaz', res.json