Skip to content

Commit

Permalink
Merge pull request #242 from NatLibFi/fix-show-project-name
Browse files Browse the repository at this point in the history
Fix invalid output of show-project; add unit test to verify
  • Loading branch information
osma authored Jan 23, 2019
2 parents 6601a12 + 4931570 commit 5d9fbfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion annif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run_show_project(project_id):
template = "{0:<20}{1}"

click.echo(template.format('Project ID:', proj.project_id))
click.echo(template.format('Project Name:', proj.project_id))
click.echo(template.format('Project Name:', proj.name))
click.echo(template.format('Language:', proj.language))


Expand Down
12 changes: 12 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ def test_list_projects_bad_arguments():


def test_show_project():
result = runner.invoke(annif.cli.cli, ['show-project', 'dummy-en'])
assert not result.exception

project_id = re.search(r'Project ID:\s+(.+)', result.output)
assert project_id.group(1) == 'dummy-en'
project_name = re.search(r'Project Name:\s+(.+)', result.output)
assert project_name.group(1) == 'Dummy English'
project_lang = re.search(r'Language:\s+(.+)', result.output)
assert project_lang.group(1) == 'en'


def test_show_project_nonexistent():
assert runner.invoke(
annif.cli.cli,
['show-project', TEMP_PROJECT]).exit_code != 0
Expand Down

0 comments on commit 5d9fbfa

Please sign in to comment.