Skip to content

Commit

Permalink
Testing autocomplete integration on all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kkalinowski-reef committed Dec 13, 2023
1 parent 601a36a commit 00eae2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
18 changes: 9 additions & 9 deletions test/integration/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 00eae2c

Please sign in to comment.