How to use test_args method in localstack

Best Python code snippet using localstack_python

test_download_integration.py

Source:test_download_integration.py Github

copy

Full Screen

1#!/usr/bin/env python32# coding=utf-83import shutil4from pathlib import Path5import pytest6from click.testing import CliRunner7from bdfr.__main__ import cli8does_test_config_exist = Path('../test_config.cfg').exists()9def copy_test_config(run_path: Path):10 shutil.copy(Path('../test_config.cfg'), Path(run_path, '../test_config.cfg'))11def create_basic_args_for_download_runner(test_args: list[str], run_path: Path):12 copy_test_config(run_path)13 out = [14 'download', str(run_path),15 '-v',16 '--config', str(Path(run_path, '../test_config.cfg')),17 '--log', str(Path(run_path, 'test_log.txt')),18 ] + test_args19 return out20@pytest.mark.online21@pytest.mark.reddit22@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')23@pytest.mark.parametrize('test_args', (24 ['-s', 'Mindustry', '-L', 1],25 ['-s', 'r/Mindustry', '-L', 1],26 ['-s', 'r/mindustry', '-L', 1],27 ['-s', 'mindustry', '-L', 1],28 ['-s', 'https://www.reddit.com/r/TrollXChromosomes/', '-L', 1],29 ['-s', 'r/TrollXChromosomes/', '-L', 1],30 ['-s', 'TrollXChromosomes/', '-L', 1],31 ['-s', 'trollxchromosomes', '-L', 1],32 ['-s', 'trollxchromosomes,mindustry,python', '-L', 1],33 ['-s', 'trollxchromosomes, mindustry, python', '-L', 1],34 ['-s', 'trollxchromosomes', '-L', 1, '--time', 'day'],35 ['-s', 'trollxchromosomes', '-L', 1, '--sort', 'new'],36 ['-s', 'trollxchromosomes', '-L', 1, '--time', 'day', '--sort', 'new'],37 ['-s', 'trollxchromosomes', '-L', 1, '--search', 'women'],38 ['-s', 'trollxchromosomes', '-L', 1, '--time', 'day', '--search', 'women'],39 ['-s', 'trollxchromosomes', '-L', 1, '--sort', 'new', '--search', 'women'],40 ['-s', 'trollxchromosomes', '-L', 1, '--time', 'day', '--sort', 'new', '--search', 'women'],41))42def test_cli_download_subreddits(test_args: list[str], tmp_path: Path):43 runner = CliRunner()44 test_args = create_basic_args_for_download_runner(test_args, tmp_path)45 result = runner.invoke(cli, test_args)46 assert result.exit_code == 047 assert 'Added submissions from subreddit ' in result.output48 assert 'Downloaded submission' in result.output49@pytest.mark.online50@pytest.mark.reddit51@pytest.mark.authenticated52@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')53@pytest.mark.parametrize('test_args', (54 ['-s', 'hentai', '-L', 10, '--search', 'red', '--authenticate'],55))56def test_cli_download_search_subreddits_authenticated(test_args: list[str], tmp_path: Path):57 runner = CliRunner()58 test_args = create_basic_args_for_download_runner(test_args, tmp_path)59 result = runner.invoke(cli, test_args)60 assert result.exit_code == 061 assert 'Added submissions from subreddit ' in result.output62 assert 'Downloaded submission' in result.output63@pytest.mark.online64@pytest.mark.reddit65@pytest.mark.authenticated66@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')67@pytest.mark.parametrize('test_args', (68 ['--subreddit', 'friends', '-L', 10, '--authenticate'],69))70def test_cli_download_user_specific_subreddits(test_args: list[str], tmp_path: Path):71 runner = CliRunner()72 test_args = create_basic_args_for_download_runner(test_args, tmp_path)73 result = runner.invoke(cli, test_args)74 assert result.exit_code == 075 assert 'Added submissions from subreddit ' in result.output76@pytest.mark.online77@pytest.mark.reddit78@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')79@pytest.mark.parametrize('test_args', (80 ['-l', 'm2601g'],81 ['-l', 'https://www.reddit.com/r/TrollXChromosomes/comments/m2601g/its_a_step_in_the_right_direction/'],82 ['-l', 'm3hxzd'], # Really long title used to overflow filename limit83 ['-l', 'm3kua3'], # Has a deleted user84 ['-l', 'm5bqkf'], # Resource leading to a 40485))86def test_cli_download_links(test_args: list[str], tmp_path: Path):87 runner = CliRunner()88 test_args = create_basic_args_for_download_runner(test_args, tmp_path)89 result = runner.invoke(cli, test_args)90 assert result.exit_code == 091@pytest.mark.online92@pytest.mark.reddit93@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')94@pytest.mark.parametrize('test_args', (95 ['--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10],96 ['--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10, '--sort', 'rising'],97 ['--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10, '--time', 'week'],98 ['--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10, '--time', 'week', '--sort', 'rising'],99))100def test_cli_download_multireddit(test_args: list[str], tmp_path: Path):101 runner = CliRunner()102 test_args = create_basic_args_for_download_runner(test_args, tmp_path)103 result = runner.invoke(cli, test_args)104 assert result.exit_code == 0105 assert 'Added submissions from multireddit ' in result.output106@pytest.mark.online107@pytest.mark.reddit108@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')109@pytest.mark.parametrize('test_args', (110 ['--user', 'helen_darten', '-m', 'xxyyzzqwerty', '-L', 10],111))112def test_cli_download_multireddit_nonexistent(test_args: list[str], tmp_path: Path):113 runner = CliRunner()114 test_args = create_basic_args_for_download_runner(test_args, tmp_path)115 result = runner.invoke(cli, test_args)116 assert result.exit_code == 0117 assert 'Failed to get submissions for multireddit' in result.output118 assert 'received 404 HTTP response' in result.output119@pytest.mark.online120@pytest.mark.reddit121@pytest.mark.authenticated122@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')123@pytest.mark.parametrize('test_args', (124 ['--user', 'djnish', '--submitted', '--user', 'FriesWithThat', '-L', 10],125 ['--user', 'me', '--upvoted', '--authenticate', '-L', 10],126 ['--user', 'me', '--saved', '--authenticate', '-L', 10],127 ['--user', 'me', '--submitted', '--authenticate', '-L', 10],128 ['--user', 'djnish', '--submitted', '-L', 10],129 ['--user', 'djnish', '--submitted', '-L', 10, '--time', 'month'],130 ['--user', 'djnish', '--submitted', '-L', 10, '--sort', 'controversial'],131))132def test_cli_download_user_data_good(test_args: list[str], tmp_path: Path):133 runner = CliRunner()134 test_args = create_basic_args_for_download_runner(test_args, tmp_path)135 result = runner.invoke(cli, test_args)136 assert result.exit_code == 0137 assert 'Downloaded submission ' in result.output138@pytest.mark.online139@pytest.mark.reddit140@pytest.mark.authenticated141@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')142@pytest.mark.parametrize('test_args', (143 ['--user', 'me', '-L', 10, '--folder-scheme', ''],144))145def test_cli_download_user_data_bad_me_unauthenticated(test_args: list[str], tmp_path: Path):146 runner = CliRunner()147 test_args = create_basic_args_for_download_runner(test_args, tmp_path)148 result = runner.invoke(cli, test_args)149 assert result.exit_code == 0150 assert 'To use "me" as a user, an authenticated Reddit instance must be used' in result.output151@pytest.mark.online152@pytest.mark.reddit153@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')154@pytest.mark.parametrize('test_args', (155 ['--subreddit', 'python', '-L', 1, '--search-existing'],156))157def test_cli_download_search_existing(test_args: list[str], tmp_path: Path):158 Path(tmp_path, 'test.txt').touch()159 runner = CliRunner()160 test_args = create_basic_args_for_download_runner(test_args, tmp_path)161 result = runner.invoke(cli, test_args)162 assert result.exit_code == 0163 assert 'Calculating hashes for' in result.output164@pytest.mark.online165@pytest.mark.reddit166@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')167@pytest.mark.parametrize('test_args', (168 ['--subreddit', 'tumblr', '-L', '25', '--skip', 'png', '--skip', 'jpg'],169 ['--subreddit', 'MaliciousCompliance', '-L', '25', '--skip', 'txt'],170 ['--subreddit', 'tumblr', '-L', '10', '--skip-domain', 'i.redd.it'],171))172def test_cli_download_download_filters(test_args: list[str], tmp_path: Path):173 runner = CliRunner()174 test_args = create_basic_args_for_download_runner(test_args, tmp_path)175 result = runner.invoke(cli, test_args)176 assert result.exit_code == 0177 assert any((string in result.output for string in ('Download filter removed ', 'filtered due to URL')))178@pytest.mark.online179@pytest.mark.reddit180@pytest.mark.slow181@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')182@pytest.mark.parametrize('test_args', (183 ['--subreddit', 'all', '-L', '100', '--sort', 'new'],184))185def test_cli_download_long(test_args: list[str], tmp_path: Path):186 runner = CliRunner()187 test_args = create_basic_args_for_download_runner(test_args, tmp_path)188 result = runner.invoke(cli, test_args)189 assert result.exit_code == 0190@pytest.mark.online191@pytest.mark.reddit192@pytest.mark.slow193@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')194@pytest.mark.parametrize('test_args', (195 ['--user', 'sdclhgsolgjeroij', '--submitted', '-L', 10],196 ['--user', 'me', '--upvoted', '-L', 10],197 ['--user', 'sdclhgsolgjeroij', '--upvoted', '-L', 10],198 ['--subreddit', 'submitters', '-L', 10], # Private subreddit199 ['--subreddit', 'donaldtrump', '-L', 10], # Banned subreddit200 ['--user', 'djnish', '--user', 'helen_darten', '-m', 'cuteanimalpics', '-L', 10],201 ['--subreddit', 'friends', '-L', 10],202))203def test_cli_download_soft_fail(test_args: list[str], tmp_path: Path):204 runner = CliRunner()205 test_args = create_basic_args_for_download_runner(test_args, tmp_path)206 result = runner.invoke(cli, test_args)207 assert result.exit_code == 0208 assert 'Downloaded' not in result.output209@pytest.mark.online210@pytest.mark.reddit211@pytest.mark.slow212@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')213@pytest.mark.parametrize('test_args', (214 ['--time', 'random'],215 ['--sort', 'random'],216))217def test_cli_download_hard_fail(test_args: list[str], tmp_path: Path):218 runner = CliRunner()219 test_args = create_basic_args_for_download_runner(test_args, tmp_path)220 result = runner.invoke(cli, test_args)221 assert result.exit_code != 0222def test_cli_download_use_default_config(tmp_path: Path):223 runner = CliRunner()224 test_args = ['download', '-vv', str(tmp_path)]225 result = runner.invoke(cli, test_args)226 assert result.exit_code == 0227@pytest.mark.online228@pytest.mark.reddit229@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')230@pytest.mark.parametrize('test_args', (231 ['-l', 'm2601g', '--exclude-id', 'm2601g'],232))233def test_cli_download_links_exclusion(test_args: list[str], tmp_path: Path):234 runner = CliRunner()235 test_args = create_basic_args_for_download_runner(test_args, tmp_path)236 result = runner.invoke(cli, test_args)237 assert result.exit_code == 0238 assert 'in exclusion list' in result.output239 assert 'Downloaded submission ' not in result.output240@pytest.mark.online241@pytest.mark.reddit242@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')243@pytest.mark.parametrize('test_args', (244 ['-l', 'm2601g', '--skip-subreddit', 'trollxchromosomes'],245 ['-s', 'trollxchromosomes', '--skip-subreddit', 'trollxchromosomes', '-L', '3'],246))247def test_cli_download_subreddit_exclusion(test_args: list[str], tmp_path: Path):248 runner = CliRunner()249 test_args = create_basic_args_for_download_runner(test_args, tmp_path)250 result = runner.invoke(cli, test_args)251 assert result.exit_code == 0252 assert 'in skip list' in result.output253 assert 'Downloaded submission ' not in result.output254@pytest.mark.online255@pytest.mark.reddit256@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')257@pytest.mark.parametrize('test_args', (258 ['--file-scheme', '{TITLE}'],259 ['--file-scheme', '{TITLE}_test_{SUBREDDIT}'],260))261def test_cli_download_file_scheme_warning(test_args: list[str], tmp_path: Path):262 runner = CliRunner()263 test_args = create_basic_args_for_download_runner(test_args, tmp_path)264 result = runner.invoke(cli, test_args)265 assert result.exit_code == 0266 assert 'Some files might not be downloaded due to name conflicts' in result.output267@pytest.mark.online268@pytest.mark.reddit269@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')270@pytest.mark.parametrize('test_args', (271 ['-l', 'm2601g', '--disable-module', 'Direct'],272 ['-l', 'nnb9vs', '--disable-module', 'YoutubeDlFallback'],273 ['-l', 'nnb9vs', '--disable-module', 'youtubedlfallback'],274))275def test_cli_download_disable_modules(test_args: list[str], tmp_path: Path):276 runner = CliRunner()277 test_args = create_basic_args_for_download_runner(test_args, tmp_path)278 result = runner.invoke(cli, test_args)279 assert result.exit_code == 0280 assert 'skipped due to disabled module' in result.output281 assert 'Downloaded submission' not in result.output282@pytest.mark.online283@pytest.mark.reddit284@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')285def test_cli_download_include_id_file(tmp_path: Path):286 test_file = Path(tmp_path, 'include.txt')287 test_args = ['--include-id-file', str(test_file)]288 test_file.write_text('odr9wg\nody576')289 runner = CliRunner()290 test_args = create_basic_args_for_download_runner(test_args, tmp_path)291 result = runner.invoke(cli, test_args)292 assert result.exit_code == 0293 assert 'Downloaded submission' in result.output294@pytest.mark.online295@pytest.mark.reddit296@pytest.mark.skipif(not does_test_config_exist, reason='A test config file is required for integration tests')297@pytest.mark.parametrize('test_args', (298 ['--ignore-user', 'ArjanEgges', '-l', 'm3hxzd'],299))300def test_cli_download_ignore_user(test_args: list[str], tmp_path: Path):301 runner = CliRunner()302 test_args = create_basic_args_for_download_runner(test_args, tmp_path)303 result = runner.invoke(cli, test_args)304 assert result.exit_code == 0305 assert 'Downloaded submission' not in result.output...

Full Screen

Full Screen

core_arguments.py

Source:core_arguments.py Github

copy

Full Screen

...13 code.append(";")14 t.write("file.jam", " ".join(code))15 t.run_build_system(["-ffile.jam"], status=status)16 t.expect_output_lines(output)17def test_args(t, *args, **kwargs):18 test(t, "args", *args, **kwargs)19def test_varargs(t, *args, **kwargs):20 test(t, "varargs", *args, **kwargs)21t = BoostBuild.Tester(pass_toolset=0)22t.write("echo_args.jam", """\23NOCARE all ;24rule echo_args ( a b ? c ? : d + : e * )25{26 ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e) ;27}28rule echo_varargs ( a b ? c ? : d + : e * : * )29{30 ECHO a= $(a) b= $(b) c= $(c) ":" d= $(d) ":" e= $(e)31 ": rest= "$(4[1]) $(4[2-])32 ": "$(5[1]) $(5[2-]) ": "$(6[1]) $(6[2-]) ": "$(7[1]) $(7[2-])33 ": "$(8[1]) $(8[2-]) ": "$(9[1]) $(9[2-]) ": "$(10[1]) $(10[2-])34 ": "$(11[1]) $(11[2-]) ": "$(12[1]) $(12[2-]) ": "$(13[1]) $(13[2-])35 ": "$(14[1]) $(14[2-]) ": "$(15[1]) $(15[2-]) ": "$(16[1]) $(16[2-])36 ": "$(17[1]) $(17[2-]) ": "$(18[1]) $(18[2-]) ": "$(19[1]) $(19[2-])37 ": "$(20[1]) $(20[2-]) ": "$(21[1]) $(21[2-]) ": "$(22[1]) $(22[2-])38 ": "$(23[1]) $(23[2-]) ": "$(24[1]) $(24[2-]) ": "$(25[1]) $(25[2-]) ;39}40""")41test_args(t, "", "* missing argument a", status=1)42test_args(t, "1 2 : 3 : 4 : 5", "* extra argument 5", status=1)43test_args(t, "a b c1 c2 : d", "* extra argument c2", status=1)44# Check modifier '?'45test_args(t, "1 2 3 : 4", "a= 1 b= 2 c= 3 : d= 4 : e=")46test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")47test_args(t, "1 2 : 3", "a= 1 b= 2 c= : d= 3 : e=")48test_args(t, "1 : 2", "a= 1 b= c= : d= 2 : e=")49# Check modifier '+'50test_args(t, "1", "* missing argument d", status=1)51test_args(t, "1 : 2 3", "a= 1 b= c= : d= 2 3 : e=")52test_args(t, "1 : 2 3 4", "a= 1 b= c= : d= 2 3 4 : e=")53# Check modifier '*'54test_args(t, "1 : 2 : 3", "a= 1 b= c= : d= 2 : e= 3")55test_args(t, "1 : 2 : 3 4", "a= 1 b= c= : d= 2 : e= 3 4")56test_args(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")57# Check varargs58test_varargs(t, "1 : 2 : 3 4 5", "a= 1 b= c= : d= 2 : e= 3 4 5")59test_varargs(t, "1 : 2 : 3 4 5 : 6", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6")60test_varargs(t, "1 : 2 : 3 4 5 : 6 7",61 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7")62test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8",63 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8")64test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9",65 "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8 : 9")66test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : "67 "16 : 17 : 18 : 19a 19b", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= 6 7 : 8 : "68 "9 : 10 : 11 : 12 : 13 : 14 : 15 : 16 : 17 : 18 : 19a 19b")69test_varargs(t, "1 : 2 : 3 4 5 : 6 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : "70 "16 : 17 : 18 : 19a 19b 19c : 20", "a= 1 b= c= : d= 2 : e= 3 4 5 : rest= "...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful