Format according to the black standard

This commit is contained in:
Serene-Arc
2022-12-03 15:11:17 +10:00
parent 96cd7d7147
commit 0873a4a2b2
60 changed files with 2160 additions and 1790 deletions

View File

@@ -9,54 +9,62 @@ from click.testing import CliRunner
from bdfr.__main__ import cli
does_test_config_exist = Path('./tests/test_config.cfg').exists()
does_test_config_exist = Path("./tests/test_config.cfg").exists()
def copy_test_config(run_path: Path):
shutil.copy(Path('./tests/test_config.cfg'), Path(run_path, 'test_config.cfg'))
shutil.copy(Path("./tests/test_config.cfg"), Path(run_path, "test_config.cfg"))
def create_basic_args_for_cloner_runner(test_args: list[str], tmp_path: Path):
copy_test_config(tmp_path)
out = [
'clone',
"clone",
str(tmp_path),
'-v',
'--config', str(Path(tmp_path, 'test_config.cfg')),
'--log', str(Path(tmp_path, 'test_log.txt')),
"-v",
"--config",
str(Path(tmp_path, "test_config.cfg")),
"--log",
str(Path(tmp_path, "test_log.txt")),
] + test_args
return out
@pytest.mark.online
@pytest.mark.reddit
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
@pytest.mark.parametrize('test_args', (
['-l', '6l7778'],
['-s', 'TrollXChromosomes/', '-L', 1],
['-l', 'eiajjw'],
['-l', 'xl0lhi'],
))
@pytest.mark.skipif(not does_test_config_exist, reason="A test config file is required for integration tests")
@pytest.mark.parametrize(
"test_args",
(
["-l", "6l7778"],
["-s", "TrollXChromosomes/", "-L", 1],
["-l", "eiajjw"],
["-l", "xl0lhi"],
),
)
def test_cli_scrape_general(test_args: list[str], tmp_path: Path):
runner = CliRunner()
test_args = create_basic_args_for_cloner_runner(test_args, tmp_path)
result = runner.invoke(cli, test_args)
assert result.exit_code == 0
assert 'Downloaded submission' in result.output
assert 'Record for entry item' in result.output
assert "Downloaded submission" in result.output
assert "Record for entry item" in result.output
@pytest.mark.online
@pytest.mark.reddit
@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')
@pytest.mark.parametrize('test_args', (
['-l', 'ijy4ch'], # user deleted post
['-l', 'kw4wjm'], # post from banned subreddit
))
@pytest.mark.skipif(not does_test_config_exist, reason="A test config file is required for integration tests")
@pytest.mark.parametrize(
"test_args",
(
["-l", "ijy4ch"], # user deleted post
["-l", "kw4wjm"], # post from banned subreddit
),
)
def test_cli_scrape_soft_fail(test_args: list[str], tmp_path: Path):
runner = CliRunner()
test_args = create_basic_args_for_cloner_runner(test_args, tmp_path)
result = runner.invoke(cli, test_args)
assert result.exit_code == 0
assert 'Downloaded submission' not in result.output
assert 'Record for entry item' not in result.output
assert "Downloaded submission" not in result.output
assert "Record for entry item" not in result.output