|
|
|
@@ -12,6 +12,21 @@ from bdfr.__main__ import cli
|
|
|
|
does_test_config_exist = Path('test_config.cfg').exists()
|
|
|
|
does_test_config_exist = Path('test_config.cfg').exists()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_basic_args_for_download_runner(test_args: list[str], tmp_path: Path):
|
|
|
|
|
|
|
|
out = [
|
|
|
|
|
|
|
|
'download', str(tmp_path),
|
|
|
|
|
|
|
|
'-v',
|
|
|
|
|
|
|
|
'--config', 'test_config.cfg',
|
|
|
|
|
|
|
|
'--log', str(Path(tmp_path, 'test_log.txt')),
|
|
|
|
|
|
|
|
] + test_args
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_basic_args_for_archive_runner(test_args: list[str], tmp_path: Path):
|
|
|
|
|
|
|
|
out = ['archive', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
|
|
|
@pytest.mark.reddit
|
|
|
|
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
|
|
|
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
|
|
|
|
@@ -36,7 +51,7 @@ does_test_config_exist = Path('test_config.cfg').exists()
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_subreddits(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_subreddits(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Added submissions from subreddit ' in result.output
|
|
|
|
assert 'Added submissions from subreddit ' in result.output
|
|
|
|
@@ -54,7 +69,7 @@ def test_cli_download_subreddits(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_links(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_links(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -70,7 +85,7 @@ def test_cli_download_links(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_multireddit(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_multireddit(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Added submissions from multireddit ' in result.output
|
|
|
|
assert 'Added submissions from multireddit ' in result.output
|
|
|
|
@@ -84,7 +99,7 @@ def test_cli_download_multireddit(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_multireddit_nonexistent(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_multireddit_nonexistent(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Failed to get submissions for multireddit' in result.output
|
|
|
|
assert 'Failed to get submissions for multireddit' in result.output
|
|
|
|
@@ -105,7 +120,7 @@ def test_cli_download_multireddit_nonexistent(test_args: list[str], tmp_path: Pa
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_user_data_good(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_user_data_good(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Downloaded submission ' in result.output
|
|
|
|
assert 'Downloaded submission ' in result.output
|
|
|
|
@@ -120,7 +135,7 @@ def test_cli_download_user_data_good(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_user_data_bad_me_unauthenticated(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_user_data_bad_me_unauthenticated(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'To use "me" as a user, an authenticated Reddit instance must be used' in result.output
|
|
|
|
assert 'To use "me" as a user, an authenticated Reddit instance must be used' in result.output
|
|
|
|
@@ -135,7 +150,7 @@ def test_cli_download_user_data_bad_me_unauthenticated(test_args: list[str], tmp
|
|
|
|
def test_cli_download_search_existing(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_search_existing(test_args: list[str], tmp_path: Path):
|
|
|
|
Path(tmp_path, 'test.txt').touch()
|
|
|
|
Path(tmp_path, 'test.txt').touch()
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Calculating hashes for' in result.output
|
|
|
|
assert 'Calculating hashes for' in result.output
|
|
|
|
@@ -149,7 +164,7 @@ def test_cli_download_search_existing(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_download_filters(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_download_filters(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Download filter removed submission' in result.output
|
|
|
|
assert 'Download filter removed submission' in result.output
|
|
|
|
@@ -164,7 +179,7 @@ def test_cli_download_download_filters(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_long(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_long(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -178,7 +193,7 @@ def test_cli_download_long(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_archive_single(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_archive_single(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['archive', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
@@ -197,7 +212,7 @@ def test_cli_archive_single(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_archive_subreddit(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_archive_subreddit(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['archive', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
@@ -211,7 +226,7 @@ def test_cli_archive_subreddit(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_archive_all_user_comments(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_archive_all_user_comments(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['archive', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -226,7 +241,7 @@ def test_cli_archive_all_user_comments(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_archive_long(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_archive_long(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['archive', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_archive_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
assert re.search(r'Writing entry .*? to file in .*? format', result.output)
|
|
|
|
@@ -243,7 +258,7 @@ def test_cli_archive_long(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -258,7 +273,7 @@ def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_hard_fail(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_hard_fail(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code != 0
|
|
|
|
assert result.exit_code != 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -278,7 +293,7 @@ def test_cli_download_use_default_config(tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_links_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_links_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'in exclusion list' in result.output
|
|
|
|
assert 'in exclusion list' in result.output
|
|
|
|
@@ -294,7 +309,7 @@ def test_cli_download_links_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_download_subreddit_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_download_subreddit_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'in skip list' in result.output
|
|
|
|
assert 'in skip list' in result.output
|
|
|
|
@@ -310,7 +325,7 @@ def test_cli_download_subreddit_exclusion(test_args: list[str], tmp_path: Path):
|
|
|
|
))
|
|
|
|
))
|
|
|
|
def test_cli_file_scheme_warning(test_args: list[str], tmp_path: Path):
|
|
|
|
def test_cli_file_scheme_warning(test_args: list[str], tmp_path: Path):
|
|
|
|
runner = CliRunner()
|
|
|
|
runner = CliRunner()
|
|
|
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
|
|
|
test_args = create_basic_args_for_download_runner(test_args, tmp_path)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
result = runner.invoke(cli, test_args)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert 'Some files might not be downloaded due to name conflicts' in result.output
|
|
|
|
assert 'Some files might not be downloaded due to name conflicts' in result.output
|
|
|
|
|