def test_get_resolved_config_calls_expand_paths( mock_get_egrc_config, mock_expand ): """ We expect the examples_dir and custom_dir to be expanded. """ def pretend_to_expand(path): if (path): return path + '/expanded' else: return None mock_get_egrc_config.return_value = config.get_empty_config() mock_expand.side_effect = pretend_to_expand # We are going to check against the default values, as the other paths have # an opportunity to already be expanded at this point. The function that # parses from the egrc returns the values expanded, eg. expected_examples_dir = pretend_to_expand(config.DEFAULT_EXAMPLES_DIR) expected_custom_dir = pretend_to_expand(config.DEFAULT_CUSTOM_DIR) actual = _call_get_resolved_config_with_defaults() assert actual.examples_dir == expected_examples_dir assert actual.custom_dir == expected_custom_dir
def test_get_resolved_config_calls_expand_paths( mock_get_egrc_config, mock_expand ): """ We expect the examples_dir and custom_dir to be expanded. """ def pretend_to_expand(path): if (path): return path + '/expanded' else: return None mock_get_egrc_config.return_value = config.get_empty_config() mock_expand.side_effect = pretend_to_expand # We are going to check against the default values, as the other paths have # an opportunity to already be expanded at this point. The function that # parses from the egrc returns the values expanded, eg. expected_examples_dir = pretend_to_expand(config.DEFAULT_EXAMPLES_DIR) expected_custom_dir = pretend_to_expand(config.DEFAULT_CUSTOM_DIR) actual = _call_get_resolved_config_with_defaults() assert_equal(actual.examples_dir, expected_examples_dir) assert_equal(actual.custom_dir, expected_custom_dir)
def test_get_egrc_returns_empty_if_no_egrc(): """ We should return an empty config if no file is given. """ expected = config.get_empty_config() _assert_about_get_egrc_config( cli_path=None, path_to_expand=config.DEFAULT_EGRC_PATH, expected_config=expected, is_file=False, )
def test_get_egrc_returns_empty_if_no_egrc(): """ We should return an empty config if no file is given. """ expected = config.get_empty_config() _assert_about_get_egrc_config( cli_path=None, cli_config_exists=False, winning_config_path=None, home_config_exists=False, expected_config=expected, xdg_dir_variable=os.path.join('path', 'to', 'xdg_home'), xdg_config_exists=False, )
def test_get_resolved_config_falls_back_to_defaults(): """ When no cli arguments or egrc arguments are present, we should use the raw defaults. """ empty_config = config.get_empty_config() expected = config.Config( examples_dir=config.DEFAULT_EXAMPLES_DIR, custom_dir=config.DEFAULT_CUSTOM_DIR, use_color=config.DEFAULT_USE_COLOR, color_config=config.get_default_color_config(), pager_cmd=config.DEFAULT_PAGER_CMD, squeeze=config.DEFAULT_SQUEEZE, subs=config.get_default_subs(), editor_cmd=config.DEFAULT_EDITOR_CMD, ) _assert_about_get_resolved_config(egrc_config=empty_config, environment_editor_cmd=None, expected_config=expected)
def test_get_resolved_config_falls_back_to_defaults(): """ When no cli arguments or egrc arguments are present, we should use the raw defaults. """ empty_config = config.get_empty_config() expected = config.Config( examples_dir=config.DEFAULT_EXAMPLES_DIR, custom_dir=config.DEFAULT_CUSTOM_DIR, use_color=config.DEFAULT_USE_COLOR, color_config=config.get_default_color_config(), pager_cmd=config.DEFAULT_PAGER_CMD, squeeze=config.DEFAULT_SQUEEZE, subs=config.get_default_subs(), editor_cmd=config.DEFAULT_EDITOR_CMD, ) _assert_about_get_resolved_config( egrc_config=empty_config, environment_editor_cmd=None, expected_config=expected )