def _helper_assert_path_isfile_not_present(config, program, file_path_for_program, defaultOrCustom, isfile, has_entry): """ Helper for asserting whether or not a default file is present. Pass in the parameters defining the program and directories and say whether or not that file should be found. """ if defaultOrCustom != 'default' and defaultOrCustom != 'custom': raise TypeError('defaultOrCustom must be default or custom, not ' + defaultOrCustom) with patch('eg.util.get_file_path_for_program', return_value=file_path_for_program) as mock_get_path: with patch('os.path.isfile', return_value=isfile) as mock_isfile: actual = None correct_dir = None if (defaultOrCustom == 'default'): correct_dir = config.examples_dir actual = util.has_default_entry_for_program(program, config) else: correct_dir = config.custom_dir actual = util.has_custom_entry_for_program(program, config) mock_get_path.assert_called_once_with(program, correct_dir) mock_isfile.assert_called_once_with(file_path_for_program) assert_equal(actual, has_entry)
def test_has_default_entry_for_program_no_examples_dir(): test_config = _create_config( examples_dir=None, custom_dir='customdir', ) program = 'cp' has_entry = util.has_default_entry_for_program(program, test_config) assert_equal(False, has_entry)
def test_has_default_entry_for_program_no_examples_dir(): test_config = config.Config(examples_dir=None, custom_dir='customdir', color_config=None, use_color=False, pager_cmd=None) program = 'cp' has_entry = util.has_default_entry_for_program(program, test_config) assert_equal(False, has_entry)
def test_has_default_entry_for_program_no_examples_dir(): test_config = config.Config( examples_dir=None, custom_dir='customdir', color_config=None, use_color=False, pager_cmd=None, squeeze=False, subs=None ) program = 'cp' has_entry = util.has_default_entry_for_program(program, test_config) assert_equal(False, has_entry)
def _helper_assert_path_isfile_not_present( config, program, file_path_for_program, defaultOrCustom, isfile, has_entry ): """ Helper for asserting whether or not a default file is present. Pass in the parameters defining the program and directories and say whether or not that file should be found. """ if defaultOrCustom != 'default' and defaultOrCustom != 'custom': raise TypeError( 'defaultOrCustom must be default or custom, not ' + defaultOrCustom ) with patch( 'eg.util.get_file_path_for_program', return_value=file_path_for_program ) as mock_get_path: with patch('os.path.isfile', return_value=isfile) as mock_isfile: actual = None correct_dir = None if (defaultOrCustom == 'default'): correct_dir = config.examples_dir actual = util.has_default_entry_for_program(program, config) else: correct_dir = config.custom_dir actual = util.has_custom_entry_for_program(program, config) mock_get_path.assert_called_once_with(program, correct_dir) mock_isfile.assert_called_once_with(file_path_for_program) assert_equal(actual, has_entry)