Skip to content

Commit

Permalink
Add tests for cli.py. Back to 100% coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Apr 3, 2016
1 parent d28cade commit 4aafa48
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# python 2 support via python-future
from __future__ import absolute_import, unicode_literals

import click.testing

import subprocess

import click.testing

from elevation import cli


Expand All @@ -21,6 +21,23 @@ def test_eio_selfcheck(mocker):
assert subprocess.check_output.call_count == 5


def test_click_merge_parent_params():
runner = click.testing.CliRunner()

@cli.eio.command()
@cli.click_merge_parent_params
def return_kwargs(**kwargs):
print(kwargs)

result = runner.invoke(cli.eio, 'return_kwargs'.split())
assert not result.exception
assert 'product' in result.output and 'cache_dir' in result.output

result = runner.invoke(return_kwargs)
assert not result.exception
assert result.output == '{}\n'


def test_eio_info(mocker, tmpdir):
root = tmpdir.join('root')
runner = click.testing.CliRunner()
Expand Down Expand Up @@ -50,6 +67,16 @@ def test_eio_clip(mocker, tmpdir):
assert not result.exception
assert subprocess.check_call.call_count == 3

mocker.patch('subprocess.check_call')
result = runner.invoke(cli.eio, ['clip'])
assert result.exception
assert subprocess.check_call.call_count == 0

mocker.patch('subprocess.check_call')
result = runner.invoke(cli.eio, 'clip --reference .'.split())
assert result.exception
assert subprocess.check_call.call_count == 0


def test_eio_clean(mocker, tmpdir):
root = tmpdir.join('root')
Expand Down

0 comments on commit 4aafa48

Please sign in to comment.