Пример #1
0
    def check_env_var_provider_config_disabled_local_state(dirname):
        provider = EnvVarProvider()
        requirement = _load_env_var_requirement(dirname, "FOO")
        local_state_file = LocalStateFile.load_for_directory(dirname)
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        assert dict(source='unset') == status.analysis.config

        assert local_state_file.get_value(['variables', 'FOO']) is None
        assert local_state_file.get_value(['disabled_variables', 'FOO']) is None

        environ = dict()

        # source=environ should mean we set disabled_variables instead of variables
        provider.set_config_values_as_strings(requirement,
                                              environ,
                                              local_state_file,
                                              'default',
                                              UserConfigOverrides(),
                                              dict(source='environ',
                                                   value="bar"))

        assert local_state_file.get_value(['variables', 'FOO']) is None
        assert local_state_file.get_value(['disabled_variables', 'FOO']) == "bar"

        config = provider.read_config(requirement, environ, local_state_file, 'default', UserConfigOverrides())
        assert config == dict(source='unset', value='bar')
Пример #2
0
    def check_env_var_provider_config_local_state(dirname):
        provider = EnvVarProvider()
        requirement = _load_env_var_requirement(dirname, "FOO_PASSWORD")
        assert requirement.encrypted
        local_state_file = LocalStateFile.load_for_directory(dirname)
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        assert dict(source='unset') == status.analysis.config

        assert local_state_file.get_value(['variables', 'FOO_PASSWORD']) is None
        assert set(keyring.fallback_data().values()) == set()

        environ = dict(CONDA_DEFAULT_ENV='/pretend/env', CONDA_ENV_PATH='/pretend/env', CONDA_PREFIX='/pretend/env')

        provider.set_config_values_as_strings(requirement,
                                              environ,
                                              local_state_file,
                                              'default',
                                              UserConfigOverrides(),
                                              dict(value="bar"))

        # should not have affected local state, should use keyring
        assert local_state_file.get_value(['variables', 'FOO_PASSWORD']) is None
        assert set(keyring.fallback_data().values()) == set(["bar"])

        # setting empty string = unset
        provider.set_config_values_as_strings(requirement,
                                              environ,
                                              local_state_file,
                                              'default',
                                              UserConfigOverrides(),
                                              dict(value=""))
        assert local_state_file.get_value(['variables', 'FOO_PASSWORD']) is None
        assert set(keyring.fallback_data().values()) == set()
Пример #3
0
    def start_local_redis(dirname):
        project = project_no_dedicated_env(dirname)
        result = _prepare_printing_errors(project, environ=minimal_environ())
        assert result
        assert 'REDIS_URL' in result.environ

        local_state_file = LocalStateFile.load_for_directory(dirname)
        state = local_state_file.get_service_run_state("REDIS_URL")
        assert 'port' in state
        port = state['port']

        assert dict(REDIS_URL=("redis://localhost:" + str(port)),
                    PROJECT_DIR=project.directory_path) == strip_environ(
                        result.environ)
        assert len(can_connect_args_list) >= 2

        pidfile = os.path.join(dirname, "services/REDIS_URL/redis.pid")
        logfile = os.path.join(dirname, "services/REDIS_URL/redis.log")
        assert os.path.exists(pidfile)
        assert os.path.exists(logfile)

        assert real_can_connect_to_socket(host='localhost', port=port)

        # be sure we generate the config html that would use the old one
        requirement = _redis_requirement()
        status = requirement.check_status(result.environ, local_state_file,
                                          'default', UserConfigOverrides())
        html = RedisProvider().config_html(requirement, result.environ,
                                           local_state_file,
                                           UserConfigOverrides(), status)
        assert 'Use the redis-server we started earlier' in html

        # now try again, and we should re-use the exact same server
        pidfile_mtime = os.path.getmtime(pidfile)
        with codecs.open(pidfile, 'r', 'utf-8') as file:
            pidfile_content = file.read()
        result2 = _prepare_printing_errors(project, environ=minimal_environ())
        assert result2

        # port should be the same, and set in the environment
        assert dict(REDIS_URL=("redis://localhost:" + str(port)),
                    PROJECT_DIR=project.directory_path) == strip_environ(
                        result2.environ)

        # no new pid file
        assert pidfile_mtime == os.path.getmtime(pidfile)
        with codecs.open(pidfile, 'r', 'utf-8') as file:
            pidfile_content2 = file.read()
        assert pidfile_content == pidfile_content2

        # now clean it up
        status = unprepare(project, result2)
        assert status

        assert not os.path.exists(pidfile)
        assert not real_can_connect_to_socket(host='localhost', port=port)

        local_state_file.load()
        assert dict() == local_state_file.get_service_run_state("REDIS_URL")
Пример #4
0
    def do_test(dirname):
        io_loop = IOLoop()
        io_loop.make_current()

        events = []

        def event_handler(event):
            events.append(event)

        project = Project(dirname)
        local_state_file = LocalStateFile.load_for_directory(dirname)

        requirement = EnvVarRequirement(registry=project.plugin_registry,
                                        env_var="FOO")
        status = requirement.check_status(dict(), local_state_file, 'default',
                                          UserConfigOverrides())
        context = ConfigurePrepareContext(dict(), local_state_file, 'default',
                                          UserConfigOverrides(), [status])
        server = UIServer(project, _no_op_prepare(context), event_handler,
                          io_loop)

        # do a get so that _requirements_by_id below exists
        get_response = http_get(io_loop, server.url)
        assert 200 == get_response.code

        req_id = list(server._application._requirements_by_id.keys())[0]
        if '%s' in name_template:
            name = name_template % req_id
        else:
            name = name_template

        encoder = MultipartEncoder({name: 'bloop'})
        body = encoder.to_string()
        headers = {'Content-Type': encoder.content_type}

        post_response = http_post(io_loop,
                                  server.url,
                                  body=body,
                                  headers=headers)
        # we just ignore bad form names, because they are assumed
        # to be some sort of hostile thing. we shouldn't ever
        # generate them on purpose.
        assert 200 == post_response.code

        server.unlisten()

        assert len(events) == 1
        assert isinstance(events[0], UIServerDoneEvent)

        out, err = capsys.readouterr()
        assert out == ""
        assert err == expected_err
Пример #5
0
    def check_env_var_provider_config(dirname):
        provider = EnvVarProvider()
        requirement = _load_env_var_requirement(dirname, "FOO")
        local_state_file = LocalStateFile.load_for_directory(dirname)
        environ = dict()
        config = provider.read_config(requirement, environ, local_state_file, 'default', UserConfigOverrides())
        assert dict(source='unset') == config

        # config html when variable is unset
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        html = provider.config_html(requirement, environ, local_state_file, UserConfigOverrides(), status)
        assert "Keep" not in html
        assert 'Use this value:' in html

        # config html when variable is unset and we have a default
        requirement.options['default'] = 'from_default'
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        html = provider.config_html(requirement, environ, local_state_file, UserConfigOverrides(), status)
        assert "Keep default 'from_default'" in html
        assert 'Use this value instead:' in html

        # config html when variable is set
        environ = dict(FOO='from_environ')
        status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
        html = provider.config_html(requirement, environ, local_state_file, UserConfigOverrides(), status)
        assert "Keep value 'from_environ'" in html
        assert 'Use this value instead:' in html

        # config html when local state override is present
        environ = dict(FOO='from_environ')
        local_state_file.set_value(['variables', 'FOO'], 'from_local_state')
        status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
        html = provider.config_html(requirement, environ, local_state_file, UserConfigOverrides(), status)
        assert "Keep value 'from_environ'" in html
        assert 'Use this value instead:' in html
Пример #6
0
    def do_test(dirname):
        io_loop = IOLoop()
        io_loop.make_current()

        events = []

        def event_handler(event):
            events.append(event)

        local_state_file = LocalStateFile.load_for_directory(dirname)

        value = local_state_file.get_value(['variables', 'FOO'])
        assert value is None

        project = Project(dirname)
        requirement = EnvVarRequirement(registry=project.plugin_registry,
                                        env_var="FOO")
        status = requirement.check_status(dict(), local_state_file, 'default',
                                          UserConfigOverrides())
        context = ConfigurePrepareContext(dict(), local_state_file, 'default',
                                          UserConfigOverrides(), [status])
        server = UIServer(project, _no_op_prepare(context), event_handler,
                          io_loop)

        get_response = http_get(io_loop, server.url)
        print(repr(get_response))

        soup = BeautifulSoup(get_response.body, _BEAUTIFUL_SOUP_BACKEND)
        field = soup.find_all("input", attrs={'type': 'text'})[0]

        assert 'name' in field.attrs

        encoder = MultipartEncoder({field['name']: 'bloop'})
        body = encoder.to_string()
        headers = {'Content-Type': encoder.content_type}

        post_response = http_post(io_loop,
                                  server.url,
                                  body=body,
                                  headers=headers)
        print(repr(post_response))

        server.unlisten()

        assert len(events) == 1
        assert isinstance(events[0], UIServerDoneEvent)

        value = local_state_file.get_value(['variables', 'FOO'])
        assert 'bloop' == value
Пример #7
0
    def do_test(dirname):
        io_loop = IOLoop()
        io_loop.make_current()

        events = []

        def event_handler(event):
            events.append(event)

        project = Project(dirname)
        local_state_file = LocalStateFile.load_for_directory(dirname)
        context = ConfigurePrepareContext(dict(), local_state_file, 'default',
                                          UserConfigOverrides(), [])
        server = UIServer(project, _no_op_prepare(context), event_handler,
                          io_loop)

        get_response = http_get(io_loop, server.url)
        print(repr(get_response))
        post_response = http_post(io_loop, server.url, body="")
        print(repr(post_response))

        server.unlisten()

        assert len(events) == 1
        assert isinstance(events[0], UIServerDoneEvent)
Пример #8
0
 def _do_nothing(stage):
     stage.set_result(
         PrepareSuccess(logs=[],
                        statuses=(),
                        command_exec_info=None,
                        environ=dict(),
                        overrides=UserConfigOverrides()), [])
     return None
Пример #9
0
 def read_config(dirname):
     local_state = LocalStateFile.load_for_directory(dirname)
     requirement = _redis_requirement()
     provider = RedisProvider()
     config = provider.read_config(requirement, dict(), local_state,
                                   'default', UserConfigOverrides())
     assert 6380 == config['lower_port']
     assert 6449 == config['upper_port']
Пример #10
0
def test_prepare_success_properties():
    result = PrepareSuccess(logs=["a"],
                            statuses=(),
                            command_exec_info=None,
                            environ=dict(),
                            overrides=UserConfigOverrides())
    assert result.statuses == ()
    assert result.status_for('FOO') is None
    assert result.status_for(EnvVarRequirement) is None
    assert result.overrides is not None
Пример #11
0
 def check_conda_default_env_is_bogus(dirname):
     requirement = _empty_default_requirement()
     project_dir_disable_dedicated_env(dirname)
     local_state = LocalStateFile.load_for_directory(dirname)
     status = requirement.check_status(
         minimal_environ_no_conda_env(**{'PROJECT_DIR': dirname}),
         local_state, 'default',
         UserConfigOverrides(inherited_env="not_a_real_env_anyone_has"))
     expected = "'not_a_real_env_anyone_has' doesn't look like it contains a Conda environment yet."
     assert expected == status.status_description
Пример #12
0
 def check_conda_default_env_not_set(dirname):
     requirement = _empty_default_requirement()
     project_dir_disable_dedicated_env(dirname)
     local_state = LocalStateFile.load_for_directory(dirname)
     status = requirement.check_status(
         minimal_environ_no_conda_env(PROJECT_DIR=dirname), local_state,
         'default', UserConfigOverrides())
     expected = "'{}' doesn't look like it contains a Conda environment yet.".format(
         os.path.join(dirname, 'envs', 'default'))
     assert expected == status.status_description
Пример #13
0
 def check_bad_scheme(dirname):
     local_state = LocalStateFile.load_for_directory(dirname)
     requirement = RedisRequirement(registry=PluginRegistry(), env_var="REDIS_URL")
     status = requirement.check_status(
         dict(REDIS_URL="http://example.com/"),
         local_state,
         'default',
         UserConfigOverrides())
     assert not status
     assert "REDIS_URL value 'http://example.com/' does not have 'redis:' scheme." == status.status_description
Пример #14
0
 def last(stage):
     assert state['state'] == 'first'
     state['state'] = 'second'
     stage.set_result(
         PrepareFailure(logs=[],
                        statuses=(),
                        errors=[],
                        environ=dict(),
                        overrides=UserConfigOverrides()),
         [])
     return None
Пример #15
0
 def last(stage):
     assert state['state'] == 'first'
     state['state'] = 'second'
     stage.set_result(
         PrepareSuccess(logs=[],
                        statuses=(),
                        command_exec_info=None,
                        environ=dict(),
                        overrides=UserConfigOverrides()),
         [])
     return None
Пример #16
0
def _no_op_prepare(config_context):
    def _do_nothing(stage):
        stage.set_result(
            PrepareSuccess(logs=[],
                           statuses=(),
                           command_exec_info=None,
                           environ=dict(),
                           overrides=UserConfigOverrides()), [])
        return None

    return _FunctionPrepareStage(dict(), UserConfigOverrides(), "Do Nothing",
                                 [], _do_nothing, config_context)
Пример #17
0
 def check_missing_package(dirname):
     requirement = CondaEnvRequirement(
         registry=PluginRegistry(),
         env_specs=dict(default=EnvSpec(
             'default', ['boguspackage', 'boguspackage2'], [])))
     project_dir_disable_dedicated_env(dirname)
     local_state = LocalStateFile.load_for_directory(dirname)
     environ = minimal_environ(PROJECT_DIR=dirname)
     status = requirement.check_status(
         environ, local_state, 'default',
         UserConfigOverrides(inherited_env=environ.get(conda_env_var)))
     assert "Conda environment is missing packages: boguspackage, boguspackage2" == status.status_description
Пример #18
0
 def check_provide_contents(dirname):
     environ = dict(foo='bar')
     local_state_file = LocalStateFile.load_for_directory(dirname)
     requirement = EnvVarRequirement(PluginRegistry(), env_var="FOO")
     status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
     context = ProvideContext(environ=environ,
                              local_state_file=local_state_file,
                              default_env_spec_name='default',
                              status=status,
                              mode=PROVIDE_MODE_DEVELOPMENT)
     assert dict(foo='bar') == context.environ
     assert context.status is status
Пример #19
0
    def set_config(dirname):
        local_state = LocalStateFile.load_for_directory(dirname)
        requirement = _redis_requirement()
        provider = RedisProvider()
        provider.set_config_values_as_strings(requirement, dict(), local_state,
                                              'default', UserConfigOverrides(),
                                              dict(lower_port="6001"))
        config = provider.read_config(requirement, dict(), local_state,
                                      'default', UserConfigOverrides())
        assert config['lower_port'] == 6001
        assert config['upper_port'] == 6449

        provider.set_config_values_as_strings(requirement, dict(), local_state,
                                              'default', UserConfigOverrides(),
                                              dict(upper_port="6700"))
        config2 = provider.read_config(requirement, dict(), local_state,
                                       'default', UserConfigOverrides())
        assert config2['lower_port'] == 6001
        assert config2['upper_port'] == 6700

        provider.set_config_values_as_strings(
            requirement, dict(), local_state, 'default', UserConfigOverrides(),
            dict(lower_port="5500", upper_port="6800"))
        config2 = provider.read_config(requirement, dict(), local_state,
                                       'default', UserConfigOverrides())
        assert config2['lower_port'] == 5500
        assert config2['upper_port'] == 6800
Пример #20
0
    def check_env_var_provider(dirname):
        provider = EnvVarProvider()
        requirement = _load_env_var_requirement(dirname, "FOO")
        local_state_file = LocalStateFile.load_for_directory(dirname)
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        context = ProvideContext(environ=dict(),
                                 local_state_file=local_state_file,
                                 default_env_spec_name='default',
                                 status=status,
                                 mode=PROVIDE_MODE_DEVELOPMENT)

        provider.provide(requirement, context=context)
        assert 'FOO' not in context.environ
Пример #21
0
 def check_provide_contents(dirname):
     environ = dict()
     local_state_file = LocalStateFile.load_for_directory(dirname)
     requirement = EnvVarRequirement(PluginRegistry(), env_var="FOO")
     status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
     context = ProvideContext(environ=environ,
                              local_state_file=local_state_file,
                              default_env_spec_name='default',
                              status=status,
                              mode=PROVIDE_MODE_DEVELOPMENT)
     with pytest.raises(IOError) as excinfo:
         context.ensure_service_directory("foo")
     assert "this is not EEXIST" in repr(excinfo.value)
Пример #22
0
 def read_config(dirname):
     local_state = LocalStateFile.load_for_directory(dirname)
     requirement = _redis_requirement()
     provider = RedisProvider()
     config = provider.read_config(requirement, dict(), local_state,
                                   'default', UserConfigOverrides())
     # revert to defaults
     assert 6380 == config['lower_port']
     assert 6449 == config['upper_port']
     # should have printed an error
     out, err = capsys.readouterr()
     assert ("Invalid port_range '%s', should be like '6380-6449'\n" %
             (port_range)) == err
Пример #23
0
    def check_env_var_provider_config_local_state(dirname):
        provider = EnvVarProvider()
        requirement = _load_env_var_requirement(dirname, "FOO")
        local_state_file = LocalStateFile.load_for_directory(dirname)
        status = requirement.check_status(dict(), local_state_file, 'default', UserConfigOverrides())
        assert dict(source='unset') == status.analysis.config

        assert local_state_file.get_value(['variables', 'FOO']) is None

        environ = dict()

        provider.set_config_values_as_strings(requirement,
                                              environ,
                                              local_state_file,
                                              'default',
                                              UserConfigOverrides(),
                                              dict(value="bar"))

        assert local_state_file.get_value(['variables', 'FOO']) == "bar"
        local_state_file.save()

        local_state_file_2 = LocalStateFile.load_for_directory(dirname)
        assert local_state_file_2.get_value(['variables', 'FOO']) == "bar"

        # setting empty string = unset
        provider.set_config_values_as_strings(requirement,
                                              environ,
                                              local_state_file,
                                              'default',
                                              UserConfigOverrides(),
                                              dict(value=""))
        assert local_state_file.get_value(['variables', 'FOO']) is None

        local_state_file.save()

        local_state_file_3 = LocalStateFile.load_for_directory(dirname)
        assert local_state_file_3.get_value(['variables', 'FOO']) is None
Пример #24
0
    def do_first(stage):
        assert state['state'] == 'start'
        state['state'] = 'first'
        stage.set_result(
            PrepareSuccess(logs=[],
                           statuses=(),
                           command_exec_info=None,
                           environ=dict(),
                           overrides=UserConfigOverrides()),
            [])

        def last(stage):
            assert state['state'] == 'first'
            state['state'] = 'second'
            stage.set_result(
                PrepareFailure(logs=[],
                               statuses=(),
                               errors=[],
                               environ=dict(),
                               overrides=UserConfigOverrides()),
                [])
            return None

        return _FunctionPrepareStage(dict(), UserConfigOverrides(), "second", [], last)
Пример #25
0
    def check_cannot_connect(dirname):
        local_state = LocalStateFile.load_for_directory(dirname)
        requirement = RedisRequirement(registry=PluginRegistry(), env_var="REDIS_URL")
        can_connect_args_list = _monkeypatch_can_connect_to_socket_fails(monkeypatch)
        status = requirement.check_status(
            dict(REDIS_URL="redis://example.com:1234/"),
            local_state,
            'default',
            UserConfigOverrides())
        assert dict(host='example.com', port=1234, timeout_seconds=0.5) == can_connect_args_list[0]
        assert dict(host='localhost', port=6379, timeout_seconds=0.5) == can_connect_args_list[1]

        assert not status
        expected = "Cannot connect to Redis at redis://example.com:1234/."
        assert expected == status.status_description
Пример #26
0
 def check_env_var_provider(dirname):
     provider = EnvVarProvider()
     requirement = _load_env_var_requirement(dirname, "FOO")
     local_state_file = LocalStateFile.load_for_directory(dirname)
     environ = dict(FOO='from_environ')
     status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
     assert dict(source='environ', value='from_environ') == status.analysis.config
     context = ProvideContext(environ=environ,
                              local_state_file=local_state_file,
                              default_env_spec_name='default',
                              status=status,
                              mode=PROVIDE_MODE_DEVELOPMENT)
     result = provider.provide(requirement, context=context)
     assert [] == result.errors
     assert 'FOO' in context.environ
     assert 'from_environ' == context.environ['FOO']
Пример #27
0
def test_run_after_success_function_when_second_stage_succeeds():
    state = {'state': 'start'}

    def do_first(stage):
        assert state['state'] == 'start'
        state['state'] = 'first'
        stage.set_result(
            PrepareSuccess(logs=[],
                           statuses=(),
                           command_exec_info=None,
                           environ=dict(),
                           overrides=UserConfigOverrides()),
            [])

        def last(stage):
            assert state['state'] == 'first'
            state['state'] = 'second'
            stage.set_result(
                PrepareSuccess(logs=[],
                               statuses=(),
                               command_exec_info=None,
                               environ=dict(),
                               overrides=UserConfigOverrides()),
                [])
            return None

        return _FunctionPrepareStage(dict(), UserConfigOverrides(), "second", [], last)

    first_stage = _FunctionPrepareStage(dict(), UserConfigOverrides(), "first", [], do_first)

    def after(updated_statuses):
        assert state['state'] == 'second'
        state['state'] = 'after'

    stage = _after_stage_success(first_stage, after)
    assert stage.overrides is first_stage.overrides
    while stage is not None:
        next_stage = stage.execute()
        result = stage.result
        if result.failed:
            assert stage.failed
            break
        else:
            assert not stage.failed
        stage = next_stage
    assert not result.failed
    assert state['state'] == 'after'
Пример #28
0
def test_skip_after_success_function_when_second_stage_fails():
    state = {'state': 'start'}

    def do_first(stage):
        assert state['state'] == 'start'
        state['state'] = 'first'
        stage.set_result(
            PrepareSuccess(logs=[],
                           statuses=(),
                           command_exec_info=None,
                           environ=dict(),
                           overrides=UserConfigOverrides()),
            [])

        def last(stage):
            assert state['state'] == 'first'
            state['state'] = 'second'
            stage.set_result(
                PrepareFailure(logs=[],
                               statuses=(),
                               errors=[],
                               environ=dict(),
                               overrides=UserConfigOverrides()),
                [])
            return None

        return _FunctionPrepareStage(dict(), UserConfigOverrides(), "second", [], last)

    first_stage = _FunctionPrepareStage(dict(), UserConfigOverrides(), "first", [], do_first)

    def after(updated_statuses):
        raise RuntimeError("should not have been called")

    stage = _after_stage_success(first_stage, after)
    assert stage.overrides is first_stage.overrides
    assert isinstance(stage.environ, dict)
    while stage is not None:
        next_stage = stage.execute()
        result = stage.result
        if result.failed:
            assert stage.failed
            break
        else:
            assert not stage.failed
        stage = next_stage
    assert result.failed
    assert state['state'] == 'second'
Пример #29
0
 def check_env_var_provider(dirname):
     provider = EnvVarProvider()
     requirement = _load_env_var_requirement(dirname, "FOO_SECRET")
     assert requirement.encrypted
     assert dict(default='from_default') == requirement.options
     local_state_file = LocalStateFile.load_for_directory(dirname)
     environ = dict()
     status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
     context = ProvideContext(environ=environ,
                              local_state_file=local_state_file,
                              default_env_spec_name='default',
                              status=status,
                              mode=PROVIDE_MODE_DEVELOPMENT)
     result = provider.provide(requirement, context=context)
     assert [] == result.errors
     assert 'FOO_SECRET' in context.environ
     assert 'from_default' == context.environ['FOO_SECRET']
Пример #30
0
 def check_env_var_provider(dirname):
     provider = EnvVarProvider()
     requirement = _load_env_var_requirement(dirname, "FOO_PASSWORD")
     assert requirement.encrypted
     local_state_file = LocalStateFile.load_for_directory(dirname)
     # set in environ to be sure we override it with local state
     environ = dict(FOO_PASSWORD='******')
     status = requirement.check_status(environ, local_state_file, 'default', UserConfigOverrides())
     assert dict(value="from_local_state", source="variables") == status.analysis.config
     context = ProvideContext(environ=environ,
                              local_state_file=local_state_file,
                              default_env_spec_name='default',
                              status=status,
                              mode=PROVIDE_MODE_DEVELOPMENT)
     result = provider.provide(requirement, context=context)
     assert [] == result.errors
     assert 'FOO_PASSWORD' in context.environ
     assert 'from_local_state' == context.environ['FOO_PASSWORD']