Exemplo n.º 1
0
def test_config_uses_custom_egrc_path():
    """Make sure we use the passed in egrc path rather than the default."""
    with patch('os.path.isfile', return_value=True):
        def_config = config.Config(
            examples_dir='eg_dir',
            custom_dir='custom_dir',
            color_config=config.get_empty_color_config(),
            use_color=False,
            pager_cmd='less is more',
            squeeze='squeeze from fake egrc',
            subs=['foo', 'bar']
        )
        egrc_path = 'test/path/to/egrc'
        with patch(
            'eg.config.get_config_tuple_from_egrc',
            return_value=def_config
        ) as mocked_get_config_from_egrc:
            config.get_resolved_config_items(
                egrc_path,
                None,
                None,
                None,
                None,
                None,
                debug=False
            )
            mocked_get_config_from_egrc.assert_called_once_with(egrc_path)
Exemplo n.º 2
0
def test_get_config_tuple_from_egrc_all_none_when_not_present():
    """
    Return correct data if the egrc has no data.

    We should return None for all values and an empty color_config if there is
    no data in the egrc.
    """
    actual = config.get_config_tuple_from_egrc('test/assets/egrc_nodata')

    empty_color_config = config.get_empty_color_config()

    target = config.Config(examples_dir=None,
                           custom_dir=None,
                           color_config=empty_color_config,
                           use_color=None,
                           pager_cmd=None)
    assert_equal(actual, target)
Exemplo n.º 3
0
def test_config_uses_custom_egrc_path():
    """Make sure we use the passed in egrc path rather than the default."""
    with patch('os.path.isfile', return_value=True):
        def_config = config.Config(
            examples_dir='eg_dir',
            custom_dir='custom_dir',
            color_config=config.get_empty_color_config(),
            use_color=False,
            pager_cmd='less is more')
        egrc_path = 'test/path/to/egrc'
        with patch('eg.config.get_config_tuple_from_egrc',
                   return_value=def_config) as mocked_method:
            config.get_resolved_config_items(egrc_path,
                                             None,
                                             None,
                                             None,
                                             None,
                                             debug=False)
            mocked_method.assert_called_once_with(egrc_path)
Exemplo n.º 4
0
def test_get_config_tuple_from_egrc_all_none_when_not_present():
    """
    Return correct data if the egrc has no data.

    We should return None for all values and an empty color_config if there is
    no data in the egrc.
    """
    actual = config.get_config_tuple_from_egrc('test/assets/egrc_nodata')

    empty_color_config = config.get_empty_color_config()

    target = config.Config(
        examples_dir=None,
        custom_dir=None,
        color_config=empty_color_config,
        use_color=None,
        pager_cmd=None
    )
    assert_equal(actual, target)
Exemplo n.º 5
0
def test_get_config_tuple_from_egrc_all_none_when_not_present():
    """
    Return correct data if the egrc has no data.

    We should return None for all values and an empty color_config if there is
    no data in the egrc.
    """
    actual = config.get_config_tuple_from_egrc(PATH_EGRC_NO_DATA)

    empty_color_config = config.get_empty_color_config()

    target = config.Config(
        examples_dir=None,
        custom_dir=None,
        color_config=empty_color_config,
        use_color=None,
        pager_cmd=None,
        squeeze=None,
        subs=None,
        editor_cmd=None,
    )
    assert actual == target
Exemplo n.º 6
0
def test_get_config_tuple_from_egrc_all_none_when_not_present():
    """
    Return correct data if the egrc has no data.

    We should return None for all values and an empty color_config if there is
    no data in the egrc.
    """
    actual = config.get_config_tuple_from_egrc(PATH_EGRC_NO_DATA)

    empty_color_config = config.get_empty_color_config()

    target = config.Config(
        examples_dir=None,
        custom_dir=None,
        color_config=empty_color_config,
        use_color=None,
        pager_cmd=None,
        squeeze=None,
        subs=None,
        editor_cmd=None,
    )
    assert actual == target