From 00eae2cb906cbe5f66bffe3a13a7e10925ab95cd Mon Sep 17 00:00:00 2001 From: Krzysztof Kalinowski Date: Wed, 13 Dec 2023 15:50:34 +0400 Subject: [PATCH] Testing autocomplete integration on all versions --- test/integration/conftest.py | 8 ++++++++ test/integration/test_autocomplete.py | 18 +++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/test/integration/conftest.py b/test/integration/conftest.py index 4d9e488f9..a6f575b15 100755 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -104,6 +104,14 @@ def cli_int_version(request) -> int: return get_cli_int_version(request.config) +@pytest.fixture(scope='session') +def cli_version(cli_int_version) -> str: + for version in CLI_VERSIONS: + if get_int_version(version) == cli_int_version: + return version + raise pytest.UsageError(f'Unknown CLI version: {cli_int_version}') + + @pytest.fixture(scope='session') def application_key() -> str: key = environ.get('B2_TEST_APPLICATION_KEY') diff --git a/test/integration/test_autocomplete.py b/test/integration/test_autocomplete.py index 6e5b0bd38..9a4f6e89d 100644 --- a/test/integration/test_autocomplete.py +++ b/test/integration/test_autocomplete.py @@ -34,16 +34,16 @@ def bashrc(homedir): @pytest.fixture(scope="module") -def autocomplete_installed(env, homedir, bashrc): +def autocomplete_installed(env, homedir, bashrc, cli_version): shell = pexpect.spawn( - 'bash -i -c "b2 install-autocomplete"', env=env, logfile=sys.stderr.buffer + f'bash -i -c "{cli_version} install-autocomplete"', env=env, logfile=sys.stderr.buffer ) try: shell.expect_exact('Autocomplete successfully installed for bash', timeout=TIMEOUT) finally: shell.close() shell.wait() - assert (homedir / '.bash_completion.d' / 'b2').is_file() + assert (homedir / '.bash_completion.d' / cli_version).is_file() assert bashrc.read_text().startswith(BASHRC_CONTENT) @@ -56,20 +56,20 @@ def shell(env): @skip_on_windows -def test_autocomplete_b2_commands(autocomplete_installed, is_running_on_docker, shell): +def test_autocomplete_b2_commands(autocomplete_installed, is_running_on_docker, shell, cli_version): if is_running_on_docker: pytest.skip('Not supported on Docker') - shell.send('b2 \t\t') + shell.send(f'{cli_version} \t\t') shell.expect_exact(["authorize-account", "download-file", "get-bucket"], timeout=TIMEOUT) @skip_on_windows def test_autocomplete_b2_only_matching_commands( - autocomplete_installed, is_running_on_docker, shell + autocomplete_installed, is_running_on_docker, shell, cli_version ): if is_running_on_docker: pytest.skip('Not supported on Docker') - shell.send('b2 delete-\t\t') + shell.send(f'{cli_version} delete-\t\t') shell.expect_exact("file", timeout=TIMEOUT) # common part of remaining cmds is autocompleted with pytest.raises(pexpect.exceptions.TIMEOUT): # no other commands are suggested @@ -78,12 +78,12 @@ def test_autocomplete_b2_only_matching_commands( @skip_on_windows def test_autocomplete_b2__download_file__b2uri( - autocomplete_installed, shell, b2_tool, bucket_name, file_name, is_running_on_docker + autocomplete_installed, shell, b2_tool, bucket_name, file_name, is_running_on_docker, cli_version ): """Test that autocomplete suggests bucket names and file names.""" if is_running_on_docker: pytest.skip('Not supported on Docker') - shell.send('b2 download_file \t\t') + shell.send(f'{cli_version} download_file \t\t') shell.expect_exact("b2://", timeout=TIMEOUT) shell.send('b2://\t\t') shell.expect_exact(bucket_name, timeout=TIMEOUT)