Add warning for non-unique file name schemes (#233)
* Add warning for non-unique file name schemes * Update README with warning
This commit is contained in:
@@ -89,7 +89,14 @@ class FileNameFormatter:
|
||||
def validate_string(test_string: str) -> bool:
|
||||
if not test_string:
|
||||
return False
|
||||
return any([f'{{{key}}}' in test_string.lower() for key in FileNameFormatter.key_terms])
|
||||
result = any([f'{{{key}}}' in test_string.lower() for key in FileNameFormatter.key_terms])
|
||||
if result:
|
||||
if 'POSTID' not in test_string:
|
||||
logger.warning(
|
||||
f'Post ID not included in this file scheme, so file names are not guaranteed to be unique')
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _format_for_windows(input_string: str) -> str:
|
||||
|
||||
@@ -254,3 +254,18 @@ def test_cli_download_links(test_args: list[str], tmp_path: Path):
|
||||
assert result.exit_code == 0
|
||||
assert 'in exclusion list' in result.output
|
||||
assert 'Downloaded submission ' not in result.output
|
||||
|
||||
|
||||
@pytest.mark.online
|
||||
@pytest.mark.reddit
|
||||
@pytest.mark.skipif(Path('test_config.cfg') is False, reason='A test config file is required for integration tests')
|
||||
@pytest.mark.parametrize('test_args', (
|
||||
['--file-scheme', '{TITLE}'],
|
||||
['--file-scheme', '{TITLE}_test_{SUBREDDIT}'],
|
||||
))
|
||||
def test_cli_file_scheme_warning(test_args: list[str], tmp_path: Path):
|
||||
runner = CliRunner()
|
||||
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
||||
result = runner.invoke(cli, test_args)
|
||||
assert result.exit_code == 0
|
||||
assert 'Post ID not included in this file scheme' in result.output
|
||||
|
||||
Reference in New Issue
Block a user