Ejemplo n.º 1
0
def test_flag_bool_unique_user():
    """Assert that a unique user can retrieve a flag, when using the local Flag.json file."""
    app = Flask(__name__)
    app.env = 'development'
    app.config['LD_SDK_KEY'] = 'https://no.flag/avail'

    user = User(username='******',
                firstname='firstname',
                lastname='lastname',
                sub='sub',
                iss='iss')

    app_env = app.env
    try:
        with app.app_context():
            flags = Flags()
            flags.init_app(app)
            app.env = 'development'
            val = flags.value('bool-flag', user)
            flag_on = flags.is_on('bool-flag', user)

        assert val
        assert flag_on
    except:  # pylint: disable=bare-except; # noqa: B901, E722
        # for tests we don't care
        assert False
    finally:
        app.env = app_env
Ejemplo n.º 2
0
def test_flags_bool_missing_flag(app):
    """Assert that a boolean (True) is returned."""
    from legal_api import flags

    with app.app_context():
        on = flags.is_on('no flag here')

    assert not on
Ejemplo n.º 3
0
def test_flags_bool(app):
    """Assert that a boolean (True) is returned."""
    from legal_api import flags

    with app.app_context():
        on = flags.is_on('bool-flag')

    assert on
Ejemplo n.º 4
0
def test_flags_bool(app):
    """Assert that a boolean (True) is returned, when using the local Flag.json file."""
    from legal_api import flags
    app.env = 'development'

    with app.app_context():
        flag_on = flags.is_on('bool-flag')

    assert flag_on
Ejemplo n.º 5
0
def test_flags_bool_using_current_app():
    """Assert that a boolean (True) is returned."""
    from legal_api import flags
    app = Flask(__name__)
    app.env = 'development'

    with app.app_context():
        on = flags.is_on('bool-flag')

    assert on
Ejemplo n.º 6
0
def test_flags_bool_missing_flag(app):
    """Assert that a boolean (False) is returned when flag doesn't exist, when using the local Flag.json file."""
    from legal_api import flags
    app_env = app.env
    try:
        with app.app_context():
            flag_on = flags.is_on('no flag here')

        assert not flag_on
    except:  # pylint: disable=bare-except; # noqa: B901, E722
        # for tests we don't care
        assert False
    finally:
        app.env = app_env
Ejemplo n.º 7
0
def test_flag_bool_unique_user(app):
    """Assert that a unique user can retrieve a flag."""
    from legal_api import flags
    user = User(username='******',
                firstname='firstname',
                lastname='lastname',
                sub='sub',
                iss='iss')
    with app.app_context():
        val = flags.value('bool-flag', user)
        on = flags.is_on('bool-flag', user)

    assert val
    assert on
Ejemplo n.º 8
0
def test_flag_bool_unique_user(app):
    """Assert that a unique user can retrieve a flag, when using the local Flag.json file."""
    from legal_api import flags
    user = User(username='******',
                firstname='firstname',
                lastname='lastname',
                sub='sub',
                iss='iss')

    app_env = app.env
    try:
        with app.app_context():
            app.env = 'development'
            val = flags.value('bool-flag', user)
            flag_on = flags.is_on('bool-flag', user)

        assert val
        assert flag_on
    except:  # pylint: disable=bare-except; # noqa: B901, E722
        # for tests we don't care
        assert False
    finally:
        app.env = app_env