def test_fflag_list():
    fflag_set_part('flag1', .955)

    output = StringIO()
    call_command('fflag_list', stdout=output)

    assert 'flag1; part=95.50%; part_ids: ~' in output.getvalue()
def test_fflag_get_existing():
    fflag_set_part('flag1', .955)

    output = StringIO()
    call_command('fflag_get', 'flag1', stdout=output)

    assert 'flag1' in output.getvalue()
    assert '95.50%' in output.getvalue()
def test_fflag_partially_enabled(key, part, k):
    fflag_set_part(key, part)

    yes = 0
    for i in range(0, 100000, k):
        yes += 1 if fflag_enabled(i, key) else 0

    assert (yes / 100000) - part < .0001
def test_fflag_for_new_unauthorized_user():
    fflag_set_part('fflag_1', 1)

    middleware = FFlagMiddleware(lambda request: HttpResponse(''))

    req = RequestFactory().get('/')
    req.session = SessionStore()
    middleware(req)

    assert req.fflag_enabled('fflag_1')
def test_fflag_rearrange():
    fflag_set_part('flag1', 1)
    fflag_set_part('flag2', 1)
    fflag_set_part('flag5', 1)
    fflag_set_part('flag4', 1)
    fflag_set_part('flag3', 1)

    assert fflag_get('flag5').id == 3
    assert fflag_get('flag4').id == 4
    assert fflag_get('flag3').id == 5
    assert caches['default'].get('fflag_max_id') == 5

    fflag_delete('flag1')
    fflag_delete('flag2')

    fflag_rearrange()

    assert fflag_get('flag5').id == 1
    assert fflag_get('flag4').id == 2
    assert fflag_get('flag3').id == 3

    assert caches['default'].get('fflag_max_id') == 3
Exemple #6
0
def test_command_fflag_list_enabled_for():
    fflag_set_part('flag1', 1)
    fflag_set_part('flag2', 0)
    fflag_set_part('flag3', 1)

    output = StringIO()
    call_command('fflag_list_enabled_for', '1', stdout=output)

    assert 'flag1' in output.getvalue()
    assert 'flag2' not in output.getvalue()
    assert 'flag3' in output.getvalue()
Exemple #7
0
def test_command_fflag_list_enabled_for_show_all():
    fflag_set_part('flag1', 1)
    fflag_set_part('flag2', 0)
    fflag_set_part('flag3', 1)

    output = StringIO()
    call_command('fflag_list_enabled_for', '1', '--show-all', stdout=output)

    assert '+flag1' in output.getvalue()
    assert '-flag2' in output.getvalue()
    assert '+flag3' in output.getvalue()
def test_fflag_list_only_enabled():
    fflag_set_part('flag1', 1)
    fflag_set_part('flag2', 0)
    fflag_set_part('flag3', 0.5)

    output = StringIO()
    call_command('fflag_list', '-1', stdout=output)

    assert 'flag1' in output.getvalue()
    assert 'flag2' not in output.getvalue()
    assert 'flag3' not in output.getvalue()
def test_fflag_disabled_for_all(key):
    fflag_set_part(key, 0)

    for i in range(1000, 2000):
        assert not fflag_enabled(i, key)