Skip to content
Snippets Groups Projects
Commit 0ec278c1 authored by James Ennis's avatar James Ennis
Browse files

completions.py: Add a test for our artifact ref autocompletions

Since the artifact subcommand group has been created, we have been able
to tab complete both element names and artifact refs as arguments to
the artifact subcommands (e.g. bst artifact log), this commit adds a
test for this.
parent 8c3ca6e2
No related branches found
No related tags found
Loading
......@@ -289,3 +289,45 @@ def test_argument_element_invalid(datafiles, cli, project, cmd, word_idx, expect
])
def test_help_commands(cli, cmd, word_idx, expected):
assert_completion(cli, cmd, word_idx, expected)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.integration
def test_argument_artifact(datafiles, cli):
project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
cwd = os.path.join(project)
# Build an import element with no dependencies (as there will only be ONE cache key)
result = cli.run(project=project, args=['build', 'import-bin.bst']) # Has no dependencies
result.assert_success()
# Get the key and the artifact ref ($project/$element_name/$key)
key = cli.get_element_key(project, 'import-bin.bst')
artifact = os.path.join('test', 'import-bin', key)
# Test autocompletion of the artifact
cmds = [
'bst artifact log ',
'bst artifact log t',
'bst artifact log test/'
]
for i, cmd in enumerate(cmds):
word_idx = 3
result = cli.run(project=project, cwd=cwd, env={
'_BST_COMPLETION': 'complete',
'COMP_WORDS': cmd,
'COMP_CWORD': str(word_idx)
})
words = []
if result.output:
words = result.output.splitlines()
if i == 0:
expected = PROJECT_ELEMENTS + [artifact] # We should now be able to see the artifact
elif i == 1:
expected = ['target.bst', artifact]
elif i == 2:
expected = [artifact]
assert artifact in words
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment